| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This program is free software; you can redistribute it and/or modify it under the terms of the | ||
| 2 | // modified version 3 of the GNU General Public License. See License.txt for details. | ||
| 3 | |||
| 4 | //! ritate_sprite_trans doesn't seem to be supported by or allegro header !? | ||
| 5 | |||
| 6 | //glibc 2.28 and later require this: -Z | ||
| 7 | #ifdef __GNUG__ | ||
| 8 | #define ALLEGRO_NO_FIX_ALIASES | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #define LOG_BMPBLIT_LEVEL 0 | ||
| 12 | #include "precompiled.h" //always first | ||
| 13 | |||
| 14 | #include "base/allegro_wrapper.h" | ||
| 15 | #include "script_drawing.h" | ||
| 16 | 11 | #include "rendertarget.h" | |
| 17 | #include "maps.h" | ||
| 18 | #include "tiles.h" | ||
| 19 | #include "zelda.h" | ||
| 20 | #include "ffscript.h" | ||
| 21 | #include "base/util.h" | ||
| 22 | #include "subscr.h" | ||
| 23 | #include "drawing.h" | ||
| 24 | using namespace util; | ||
| 25 | extern FFScript FFCore; | ||
| 26 | extern ZModule zcm; | ||
| 27 | extern refInfo *ri; | ||
| 28 | extern script_bitmaps scb; | ||
| 29 | #include <stdio.h> | ||
| 30 | #include <fstream> | ||
| 31 | |||
| 32 | #define DegtoFix(d) ((d)*0.7111111111111) | ||
| 33 | #define RadtoFix(d) ((d)*40.743665431525) | ||
| 34 | |||
| 35 | ✗ | inline double sd_log2( double n ) | |
| 36 | { | ||
| 37 | // log(n)/log(2) is log2. | ||
| 38 | ✗ | double v = log( (double)n ) / log( (double)2 ); | |
| 39 | ✗ | return v; | |
| 40 | } | ||
| 41 | |||
| 42 | ✗ | inline bool isPowerOfTwo(int32_t n) | |
| 43 | { | ||
| 44 | ✗ | if(n==0) | |
| 45 | ✗ | return false; | |
| 46 | |||
| 47 | ✗ | return (ceil(sd_log2(n)) == floor(sd_log2(n))); | |
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | template<class T> inline | ||
| 53 | ✗ | fixed degrees_to_fixed(T d) | |
| 54 | { | ||
| 55 | ✗ | return ftofix(DegtoFix(d)); | |
| 56 | } | ||
| 57 | template<class T> inline | ||
| 58 | fixed radians_to_fixed(T d) | ||
| 59 | { | ||
| 60 | return ftofix(RadtoFix(d)); | ||
| 61 | } | ||
| 62 | |||
| 63 | BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0; | ||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | 53566 | FONT *get_zc_font(int32_t index) | |
| 68 | { | ||
| 69 | //return getfont(index); | ||
| 70 |
1/71✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 53566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
|
53566 | switch(index) |
| 71 | { | ||
| 72 | default: | ||
| 73 | ✗ | return zfont; | |
| 74 | |||
| 75 | case font_z3font: | ||
| 76 | ✗ | return z3font; | |
| 77 | |||
| 78 | case font_z3smallfont: | ||
| 79 | 53566 | return z3smallfont; | |
| 80 | |||
| 81 | case font_deffont: | ||
| 82 | ✗ | return deffont; | |
| 83 | |||
| 84 | case font_lfont: | ||
| 85 | ✗ | return lfont; | |
| 86 | |||
| 87 | case font_lfont_l: | ||
| 88 | ✗ | return lfont_l; | |
| 89 | |||
| 90 | case font_pfont: | ||
| 91 | ✗ | return pfont; | |
| 92 | |||
| 93 | case font_mfont: | ||
| 94 | ✗ | return mfont; | |
| 95 | |||
| 96 | case font_ztfont: | ||
| 97 | ✗ | return ztfont; | |
| 98 | |||
| 99 | case font_sfont: | ||
| 100 | ✗ | return sfont; | |
| 101 | |||
| 102 | case font_sfont2: | ||
| 103 | ✗ | return sfont2; | |
| 104 | |||
| 105 | case font_spfont: | ||
| 106 | ✗ | return spfont; | |
| 107 | |||
| 108 | case font_ssfont1: | ||
| 109 | ✗ | return ssfont1; | |
| 110 | |||
| 111 | case font_ssfont2: | ||
| 112 | ✗ | return ssfont2; | |
| 113 | |||
| 114 | case font_ssfont3: | ||
| 115 | ✗ | return ssfont3; | |
| 116 | |||
| 117 | case font_ssfont4: | ||
| 118 | ✗ | return ssfont4; | |
| 119 | |||
| 120 | case font_gblafont: | ||
| 121 | ✗ | return gblafont; | |
| 122 | |||
| 123 | case font_goronfont: | ||
| 124 | ✗ | return goronfont; | |
| 125 | |||
| 126 | case font_zoranfont: | ||
| 127 | ✗ | return zoranfont; | |
| 128 | |||
| 129 | case font_hylian1font: | ||
| 130 | ✗ | return hylian1font; | |
| 131 | |||
| 132 | case font_hylian2font: | ||
| 133 | ✗ | return hylian2font; | |
| 134 | |||
| 135 | case font_hylian3font: | ||
| 136 | ✗ | return hylian3font; | |
| 137 | |||
| 138 | case font_hylian4font: | ||
| 139 | ✗ | return hylian4font; | |
| 140 | |||
| 141 | case font_gboraclefont: | ||
| 142 | ✗ | return gboraclefont; | |
| 143 | |||
| 144 | case font_gboraclepfont: | ||
| 145 | ✗ | return gboraclepfont; | |
| 146 | |||
| 147 | case font_dsphantomfont: | ||
| 148 | ✗ | return dsphantomfont; | |
| 149 | |||
| 150 | case font_dsphantompfont: | ||
| 151 | ✗ | return dsphantompfont; | |
| 152 | ✗ | case font_atari800font: return atari800font; | |
| 153 | ✗ | case font_acornfont: return acornfont; | |
| 154 | ✗ | case font_adosfont: return adosfont; | |
| 155 | ✗ | case font_baseallegrofont: return baseallegrofont; | |
| 156 | ✗ | case font_apple2font: return apple2font; | |
| 157 | ✗ | case font_apple280colfont: return apple280colfont; | |
| 158 | ✗ | case font_apple2gsfont: return apple2gsfont; | |
| 159 | ✗ | case font_aquariusfont: return aquariusfont; | |
| 160 | ✗ | case font_atari400font: return atari400font; | |
| 161 | ✗ | case font_c64font: return c64font; | |
| 162 | ✗ | case font_c64hiresfont: return c64hiresfont; | |
| 163 | ✗ | case font_cgafont: return cgafont; | |
| 164 | ✗ | case font_cocofont: return cocofont; | |
| 165 | ✗ | case font_coco2font: return coco2font; | |
| 166 | ✗ | case font_coupefon: return coupefont; | |
| 167 | ✗ | case font_cpcfon: return cpcfont; | |
| 168 | ✗ | case font_fantasyfon: return fantasyfont; | |
| 169 | ✗ | case font_fdskanafon: return fdskanafont; | |
| 170 | ✗ | case font_fdslikefon: return fdslikefont; | |
| 171 | ✗ | case font_fdsromanfon: return fdsromanfont; | |
| 172 | ✗ | case font_finalffont: return finalffont; | |
| 173 | ✗ | case font_futharkfont: return futharkfont; | |
| 174 | ✗ | case font_gaiafont: return gaiafont; | |
| 175 | ✗ | case font_hirafont: return hirafont; | |
| 176 | ✗ | case font_jpfont: return jpfont; | |
| 177 | ✗ | case font_kongfont: return kongfont; | |
| 178 | ✗ | case font_manafont: return manafont; | |
| 179 | ✗ | case font_mlfont: return mlfont; | |
| 180 | ✗ | case font_motfont: return motfont; | |
| 181 | ✗ | case font_msxmode0font: return msxmode0font; | |
| 182 | ✗ | case font_msxmode1font: return msxmode1font; | |
| 183 | ✗ | case font_petfont: return petfont; | |
| 184 | ✗ | case font_pstartfont: return pstartfont; | |
| 185 | ✗ | case font_saturnfont: return saturnfont; | |
| 186 | ✗ | case font_scififont: return scififont; | |
| 187 | ✗ | case font_sherwoodfont: return sherwoodfont; | |
| 188 | ✗ | case font_sinqlfont: return sinqlfont; | |
| 189 | ✗ | case font_spectrumfont: return spectrumfont; | |
| 190 | ✗ | case font_speclgfont: return speclgfont; | |
| 191 | ✗ | case font_ti99font: return ti99font; | |
| 192 | ✗ | case font_trsfont: return trsfont; | |
| 193 | ✗ | case font_z2font: return z2font; | |
| 194 | ✗ | case font_zxfont: return zxfont; | |
| 195 | ✗ | case font_lisafont: return lisafont; | |
| 196 | } | ||
| 197 | 53566 | } | |
| 198 | |||
| 199 | |||
| 200 | class TileHelper | ||
| 201 | { | ||
| 202 | public: | ||
| 203 | |||
| 204 | ✗ | static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0) | |
| 205 | { | ||
| 206 | // Past the end of the tile page? | ||
| 207 | ✗ | if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW) | |
| 208 | { | ||
| 209 | ✗ | byte w2=(tile+w)%TILES_PER_ROW; | |
| 210 | ✗ | OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip); | |
| 211 | ✗ | OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip); | |
| 212 | ✗ | return; | |
| 213 | } | ||
| 214 | |||
| 215 | ✗ | switch(flip) | |
| 216 | { | ||
| 217 | case 1: | ||
| 218 | ✗ | for(int32_t j=0; j<h; j++) | |
| 219 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 220 | ✗ | oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip); | |
| 221 | |||
| 222 | ✗ | break; | |
| 223 | |||
| 224 | case 2: | ||
| 225 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 226 | ✗ | for(int32_t k=0; k<w; k++) | |
| 227 | ✗ | oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip); | |
| 228 | |||
| 229 | ✗ | break; | |
| 230 | |||
| 231 | case 3: | ||
| 232 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 233 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 234 | ✗ | oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip); | |
| 235 | |||
| 236 | ✗ | break; | |
| 237 | |||
| 238 | ✗ | case 0: | |
| 239 | default: | ||
| 240 | ✗ | for(int32_t j=0; j<h; j++) | |
| 241 | ✗ | for(int32_t k=0; k<w; k++) | |
| 242 | ✗ | oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip); | |
| 243 | |||
| 244 | ✗ | break; | |
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | ✗ | static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0) | |
| 249 | { | ||
| 250 | ✗ | overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows); | |
| 251 | } | ||
| 252 | |||
| 253 | ✗ | static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0) | |
| 254 | { | ||
| 255 | ✗ | if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW) | |
| 256 | { | ||
| 257 | ✗ | byte w2=(tile+w)%TILES_PER_ROW; | |
| 258 | ✗ | OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip); | |
| 259 | ✗ | OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip); | |
| 260 | ✗ | return; | |
| 261 | } | ||
| 262 | |||
| 263 | ✗ | switch(flip) | |
| 264 | { | ||
| 265 | case 1: | ||
| 266 | ✗ | for(int32_t j=0; j<h; j++) | |
| 267 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 268 | ✗ | overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip); | |
| 269 | |||
| 270 | ✗ | break; | |
| 271 | |||
| 272 | case 2: | ||
| 273 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 274 | ✗ | for(int32_t k=0; k<w; k++) | |
| 275 | ✗ | overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip); | |
| 276 | |||
| 277 | ✗ | break; | |
| 278 | |||
| 279 | case 3: | ||
| 280 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 281 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 282 | ✗ | overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip); | |
| 283 | |||
| 284 | ✗ | break; | |
| 285 | |||
| 286 | default: | ||
| 287 | ✗ | for(int32_t j=0; j<h; j++) | |
| 288 | ✗ | for(int32_t k=0; k<w; k++) | |
| 289 | ✗ | overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip); | |
| 290 | |||
| 291 | ✗ | break; | |
| 292 | } | ||
| 293 | } | ||
| 294 | |||
| 295 | ✗ | static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0) | |
| 296 | { | ||
| 297 | ✗ | if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW) | |
| 298 | { | ||
| 299 | ✗ | byte w2=(tile+w)%TILES_PER_ROW; | |
| 300 | ✗ | OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity); | |
| 301 | ✗ | OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity); | |
| 302 | ✗ | return; | |
| 303 | } | ||
| 304 | |||
| 305 | ✗ | switch(flip) | |
| 306 | { | ||
| 307 | case 1: | ||
| 308 | ✗ | for(int32_t j=0; j<h; j++) | |
| 309 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 310 | ✗ | overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity); | |
| 311 | |||
| 312 | ✗ | break; | |
| 313 | |||
| 314 | case 2: | ||
| 315 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 316 | ✗ | for(int32_t k=0; k<w; k++) | |
| 317 | ✗ | overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity); | |
| 318 | |||
| 319 | ✗ | break; | |
| 320 | |||
| 321 | case 3: | ||
| 322 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 323 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 324 | ✗ | overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity); | |
| 325 | |||
| 326 | ✗ | break; | |
| 327 | |||
| 328 | default: | ||
| 329 | ✗ | for(int32_t j=0; j<h; j++) | |
| 330 | ✗ | for(int32_t k=0; k<w; k++) | |
| 331 | ✗ | overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity); | |
| 332 | |||
| 333 | ✗ | break; | |
| 334 | } | ||
| 335 | } | ||
| 336 | |||
| 337 | ✗ | static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0) | |
| 338 | { | ||
| 339 | ✗ | if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW) | |
| 340 | { | ||
| 341 | ✗ | byte w2=(tile+w)%TILES_PER_ROW; | |
| 342 | ✗ | PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity); | |
| 343 | ✗ | PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity); | |
| 344 | ✗ | return; | |
| 345 | } | ||
| 346 | |||
| 347 | ✗ | switch(flip) | |
| 348 | { | ||
| 349 | case 1: | ||
| 350 | ✗ | for(int32_t j=0; j<h; j++) | |
| 351 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 352 | ✗ | puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity); | |
| 353 | |||
| 354 | ✗ | break; | |
| 355 | |||
| 356 | case 2: | ||
| 357 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 358 | ✗ | for(int32_t k=0; k<w; k++) | |
| 359 | ✗ | puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity); | |
| 360 | |||
| 361 | ✗ | break; | |
| 362 | |||
| 363 | case 3: | ||
| 364 | ✗ | for(int32_t j=h-1; j>=0; j--) | |
| 365 | ✗ | for(int32_t k=w-1; k>=0; k--) | |
| 366 | ✗ | puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity); | |
| 367 | |||
| 368 | ✗ | break; | |
| 369 | |||
| 370 | default: | ||
| 371 | ✗ | for(int32_t j=0; j<h; j++) | |
| 372 | ✗ | for(int32_t k=0; k<w; k++) | |
| 373 | ✗ | puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity); | |
| 374 | |||
| 375 | ✗ | break; | |
| 376 | } | ||
| 377 | } | ||
| 378 | }; | ||
| 379 | |||
| 380 | |||
| 381 | |||
| 382 | |||
| 383 | 22803 | void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 384 | { | ||
| 385 | //sdci[1]=layer | ||
| 386 | //sdci[2]=x | ||
| 387 | //sdci[3]=y | ||
| 388 | //sdci[4]=x2 | ||
| 389 | //sdci[5]=y2 | ||
| 390 | //sdci[6]=color | ||
| 391 | //sdci[7]=scale factor | ||
| 392 | //sdci[8]=rotation anchor x | ||
| 393 | //sdci[9]=rotation anchor y | ||
| 394 | //sdci[10]=rotation angle | ||
| 395 | //sdci[11]=fill | ||
| 396 | //sdci[12]=opacity | ||
| 397 |
1/2✓ Branch 0 taken 22803 times.
✗ Branch 1 not taken.
|
22803 | if(sdci[7]==0) //scale |
| 398 | { | ||
| 399 | ✗ | return; | |
| 400 | } | ||
| 401 | |||
| 402 | 22803 | int32_t x1=sdci[2]/10000; | |
| 403 | 22803 | int32_t y1=sdci[3]/10000; | |
| 404 | 22803 | int32_t x2=sdci[4]/10000; | |
| 405 | 22803 | int32_t y2=sdci[5]/10000; | |
| 406 | |||
| 407 |
1/2✓ Branch 0 taken 22803 times.
✗ Branch 1 not taken.
|
22803 | if(x1>x2) |
| 408 | { | ||
| 409 | ✗ | zc_swap(x1,x2); | |
| 410 | } | ||
| 411 | |||
| 412 |
1/2✓ Branch 0 taken 22803 times.
✗ Branch 1 not taken.
|
22803 | if(y1>y2) |
| 413 | { | ||
| 414 | ✗ | zc_swap(y1,y2); | |
| 415 | } | ||
| 416 | |||
| 417 |
1/2✓ Branch 0 taken 22803 times.
✗ Branch 1 not taken.
|
22803 | if(sdci[7] != 10000) |
| 418 | { | ||
| 419 | ✗ | int32_t w=x2-x1+1; | |
| 420 | ✗ | int32_t h=y2-y1+1; | |
| 421 | ✗ | int32_t w2=(w*sdci[7])/10000; | |
| 422 | ✗ | int32_t h2=(h*sdci[7])/10000; | |
| 423 | ✗ | x1=x1-((w2-w)/2); | |
| 424 | ✗ | x2=x2+((w2-w)/2); | |
| 425 | ✗ | y1=y1-((h2-h)/2); | |
| 426 | ✗ | y2=y2+((h2-h)/2); | |
| 427 | } | ||
| 428 | |||
| 429 | 22803 | int32_t color=sdci[6]/10000; | |
| 430 | |||
| 431 |
1/2✓ Branch 0 taken 22803 times.
✗ Branch 1 not taken.
|
22803 | if(sdci[12]/10000<=127) //translucent |
| 432 | { | ||
| 433 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 434 | } | ||
| 435 | |||
| 436 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22803 times.
|
22803 | if(sdci[10]==0) //no rotation |
| 437 | { | ||
| 438 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22803 times.
|
22803 | if(sdci[11]) //filled |
| 439 | { | ||
| 440 | 22803 | rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 441 | 22803 | } | |
| 442 | else //outline | ||
| 443 | { | ||
| 444 | ✗ | rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 445 | } | ||
| 446 | 22803 | } | |
| 447 | else //rotate | ||
| 448 | { | ||
| 449 | int32_t xy[16]; | ||
| 450 | ✗ | int32_t rx=sdci[8]/10000; | |
| 451 | ✗ | int32_t ry=sdci[9]/10000; | |
| 452 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 453 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 454 | ✗ | fixed ra=ra1+ra2; | |
| 455 | ✗ | ra = (ra/360)*256; | |
| 456 | |||
| 457 | ✗ | fixed fcosa = fixcos(ra); | |
| 458 | ✗ | fixed fsina = fixsin(ra); | |
| 459 | |||
| 460 | ✗ | xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1 | |
| 461 | ✗ | xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1 | |
| 462 | ✗ | xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2 | |
| 463 | ✗ | xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1 | |
| 464 | ✗ | xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2 | |
| 465 | ✗ | xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2 | |
| 466 | ✗ | xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1 | |
| 467 | ✗ | xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2 | |
| 468 | ✗ | xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1 | |
| 469 | ✗ | xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1 | |
| 470 | ✗ | xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2 | |
| 471 | ✗ | xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1 | |
| 472 | ✗ | xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2 | |
| 473 | ✗ | xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2 | |
| 474 | ✗ | xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1 | |
| 475 | ✗ | xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2 | |
| 476 | |||
| 477 | ✗ | if(sdci[11]) //filled | |
| 478 | { | ||
| 479 | ✗ | polygon(bmp, 4, xy, color); | |
| 480 | } | ||
| 481 | else //outline | ||
| 482 | { | ||
| 483 | ✗ | line(bmp, xy[0], xy[1], xy[10], xy[11], color); | |
| 484 | ✗ | line(bmp, xy[2], xy[3], xy[12], xy[13], color); | |
| 485 | ✗ | line(bmp, xy[4], xy[5], xy[14], xy[15], color); | |
| 486 | ✗ | line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color); | |
| 487 | } | ||
| 488 | } | ||
| 489 | |||
| 490 | 22803 | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 491 | 22803 | } | |
| 492 | |||
| 493 | ✗ | void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 494 | { | ||
| 495 | //sdci[1]=layer | ||
| 496 | //sdci[2]=x | ||
| 497 | //sdci[3]=y | ||
| 498 | //sdci[4]=tile | ||
| 499 | //sdci[5]=cset | ||
| 500 | //sdci[6]=width | ||
| 501 | //sdci[7]=height | ||
| 502 | //sdci[8]=overlay | ||
| 503 | //sdci[9]=opacity | ||
| 504 | |||
| 505 | ✗ | int32_t x=sdci[2]/10000; | |
| 506 | ✗ | int32_t y=sdci[3]/10000; | |
| 507 | |||
| 508 | ✗ | int32_t tile=sdci[4]/10000; | |
| 509 | ✗ | int32_t cs=sdci[5]/10000; | |
| 510 | ✗ | int32_t w=sdci[6]/10000; | |
| 511 | ✗ | int32_t h=sdci[7]/10000; | |
| 512 | ✗ | bool overlay=sdci[8]; | |
| 513 | ✗ | bool trans=(sdci[9]/10000<=127); | |
| 514 | |||
| 515 | ✗ | frame2x2(bmp, &QMisc, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans); | |
| 516 | } | ||
| 517 | |||
| 518 | |||
| 519 | |||
| 520 | ✗ | void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 521 | { | ||
| 522 | //sdci[1]=layer | ||
| 523 | //sdci[2]=x | ||
| 524 | //sdci[3]=y | ||
| 525 | //sdci[4]=radius | ||
| 526 | //sdci[5]=color | ||
| 527 | //sdci[6]=scale factor | ||
| 528 | //sdci[7]=rotation anchor x | ||
| 529 | //sdci[8]=rotation anchor y | ||
| 530 | //sdci[9]=rotation angle | ||
| 531 | //sdci[10]=fill | ||
| 532 | //sdci[11]=opacity | ||
| 533 | ✗ | if(sdci[6]==0) //scale | |
| 534 | { | ||
| 535 | ✗ | return; | |
| 536 | } | ||
| 537 | |||
| 538 | ✗ | int32_t x1=sdci[2]/10000; | |
| 539 | ✗ | int32_t y1=sdci[3]/10000; | |
| 540 | ✗ | qword r=sdci[4]; | |
| 541 | |||
| 542 | ✗ | if(sdci[6] != 10000) | |
| 543 | { | ||
| 544 | ✗ | r*=sdci[6]; | |
| 545 | ✗ | r/=10000; | |
| 546 | } | ||
| 547 | |||
| 548 | ✗ | r/=10000; | |
| 549 | ✗ | int32_t color=sdci[5]/10000; | |
| 550 | |||
| 551 | ✗ | if(sdci[11]/10000<=127) //translucent | |
| 552 | { | ||
| 553 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 554 | } | ||
| 555 | |||
| 556 | ✗ | if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation | |
| 557 | { | ||
| 558 | int32_t xy[2]; | ||
| 559 | ✗ | int32_t rx=sdci[7]/10000; | |
| 560 | ✗ | int32_t ry=sdci[8]/10000; | |
| 561 | ✗ | fixed ra1=itofix(sdci[9]%10000)/10000; | |
| 562 | ✗ | fixed ra2=itofix(sdci[9]/10000); | |
| 563 | ✗ | fixed ra=ra1+ra2; | |
| 564 | ✗ | ra = (ra/360)*256; | |
| 565 | |||
| 566 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 567 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 568 | ✗ | x1=xy[0]; | |
| 569 | ✗ | y1=xy[1]; | |
| 570 | } | ||
| 571 | |||
| 572 | ✗ | if(sdci[10]) //filled | |
| 573 | { | ||
| 574 | ✗ | circlefill(bmp, x1+xoffset, y1+yoffset, r, color); | |
| 575 | } | ||
| 576 | else //outline | ||
| 577 | { | ||
| 578 | ✗ | circle(bmp, x1+xoffset, y1+yoffset, r, color); | |
| 579 | } | ||
| 580 | |||
| 581 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 582 | } | ||
| 583 | |||
| 584 | |||
| 585 | ✗ | void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 586 | { | ||
| 587 | //sdci[1]=layer | ||
| 588 | //sdci[2]=x | ||
| 589 | //sdci[3]=y | ||
| 590 | //sdci[4]=radius | ||
| 591 | //sdci[5]=start angle | ||
| 592 | //sdci[6]=end angle | ||
| 593 | //sdci[7]=color | ||
| 594 | //sdci[8]=scale factor | ||
| 595 | //sdci[9]=rotation anchor x | ||
| 596 | //sdci[10]=rotation anchor y | ||
| 597 | //sdci[11]=rotation angle | ||
| 598 | //sdci[12]=closed | ||
| 599 | //sdci[13]=fill | ||
| 600 | //sdci[14]=opacity | ||
| 601 | |||
| 602 | ✗ | if(sdci[8]==0) //scale | |
| 603 | { | ||
| 604 | ✗ | return; | |
| 605 | } | ||
| 606 | |||
| 607 | ✗ | int32_t cx=sdci[2]/10000; | |
| 608 | ✗ | int32_t cy=sdci[3]/10000; | |
| 609 | ✗ | qword r=sdci[4]; | |
| 610 | |||
| 611 | ✗ | if(sdci[8] != 10000) | |
| 612 | { | ||
| 613 | ✗ | r*=sdci[8]; | |
| 614 | ✗ | r/=10000; | |
| 615 | } | ||
| 616 | |||
| 617 | ✗ | r/=10000; | |
| 618 | |||
| 619 | ✗ | int32_t color=sdci[7]/10000; | |
| 620 | |||
| 621 | ✗ | fixed ra1=itofix(sdci[11]%10000)/10000; | |
| 622 | ✗ | fixed ra2=itofix(sdci[11]/10000); | |
| 623 | ✗ | fixed ra=ra1+ra2; | |
| 624 | ✗ | ra = (ra/360)*256; | |
| 625 | |||
| 626 | |||
| 627 | ✗ | fixed a1=itofix(sdci[5]%10000)/10000; | |
| 628 | ✗ | fixed a2=itofix(sdci[5]/10000); | |
| 629 | ✗ | fixed sa=a1+a2; | |
| 630 | ✗ | sa = (sa/360)*256; | |
| 631 | |||
| 632 | ✗ | a1=itofix(sdci[6]%10000)/10000; | |
| 633 | ✗ | a2=itofix(sdci[6]/10000); | |
| 634 | ✗ | fixed ea=a1+a2; | |
| 635 | ✗ | ea = (ea/360)*256; | |
| 636 | |||
| 637 | ✗ | if(sdci[11]!=0) //rotation | |
| 638 | { | ||
| 639 | ✗ | int32_t rx=sdci[9]/10000; | |
| 640 | ✗ | int32_t ry=sdci[10]/10000; | |
| 641 | |||
| 642 | ✗ | cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1 | |
| 643 | ✗ | cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1 | |
| 644 | ✗ | ea-=ra; | |
| 645 | ✗ | sa-=ra; | |
| 646 | } | ||
| 647 | |||
| 648 | ✗ | int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2); | |
| 649 | ✗ | int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2); | |
| 650 | |||
| 651 | ✗ | if(sdci[12]) //closed | |
| 652 | { | ||
| 653 | ✗ | if(sdci[13]) //filled | |
| 654 | { | ||
| 655 | ✗ | clear_bitmap(prim_bmp); | |
| 656 | ✗ | arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 657 | ✗ | line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color); | |
| 658 | ✗ | line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color); | |
| 659 | ✗ | floodfill(prim_bmp, zc_max(0,fx)+xoffset, zc_max(0,fy)+yoffset, color); | |
| 660 | |||
| 661 | ✗ | if(sdci[14]/10000<=127) //translucent | |
| 662 | { | ||
| 663 | ✗ | draw_trans_sprite(bmp, prim_bmp, 0,0); | |
| 664 | } | ||
| 665 | else | ||
| 666 | { | ||
| 667 | ✗ | draw_sprite(bmp, prim_bmp, 0,0); | |
| 668 | } | ||
| 669 | } | ||
| 670 | else | ||
| 671 | { | ||
| 672 | ✗ | arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 673 | ✗ | line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color); | |
| 674 | ✗ | line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color); | |
| 675 | } | ||
| 676 | } | ||
| 677 | else | ||
| 678 | { | ||
| 679 | ✗ | if(sdci[14]/10000<=127) //translucent | |
| 680 | { | ||
| 681 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 682 | } | ||
| 683 | |||
| 684 | ✗ | arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 685 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 686 | } | ||
| 687 | } | ||
| 688 | |||
| 689 | |||
| 690 | ✗ | void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 691 | { | ||
| 692 | //sdci[1]=layer | ||
| 693 | //sdci[2]=x | ||
| 694 | //sdci[3]=y | ||
| 695 | //sdci[4]=radiusx | ||
| 696 | //sdci[5]=radiusy | ||
| 697 | //sdci[6]=color | ||
| 698 | //sdci[7]=scale factor | ||
| 699 | //sdci[8]=rotation anchor x | ||
| 700 | //sdci[9]=rotation anchor y | ||
| 701 | //sdci[10]=rotation angle | ||
| 702 | //sdci[11]=fill | ||
| 703 | //sdci[12]=opacity | ||
| 704 | |||
| 705 | ✗ | if(sdci[7]==0) //scale | |
| 706 | { | ||
| 707 | ✗ | return; | |
| 708 | } | ||
| 709 | |||
| 710 | ✗ | int32_t x1=sdci[2]/10000; | |
| 711 | ✗ | int32_t y1=sdci[3]/10000; | |
| 712 | ✗ | int32_t radx=sdci[4]/10000; | |
| 713 | ✗ | radx*=sdci[7]/10000; | |
| 714 | ✗ | int32_t rady=sdci[5]/10000; | |
| 715 | ✗ | rady*=sdci[7]/10000; | |
| 716 | ✗ | int32_t color=sdci[6]/10000; | |
| 717 | ✗ | float rotation = sdci[10]/10000; | |
| 718 | |||
| 719 | ✗ | int32_t rx=sdci[8]/10000; | |
| 720 | ✗ | int32_t ry=sdci[9]/10000; | |
| 721 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 722 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 723 | ✗ | fixed ra=ra1+ra2; | |
| 724 | ✗ | ra = (ra/360)*256; | |
| 725 | |||
| 726 | int32_t xy[2]; | ||
| 727 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 728 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 729 | ✗ | x1=xy[0]; | |
| 730 | ✗ | y1=xy[1]; | |
| 731 | |||
| 732 | ✗ | if(radx<1||rady<1||radx>255||rady>255) return; | |
| 733 | |||
| 734 | ✗ | BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1); | |
| 735 | |||
| 736 | ✗ | if(sdci[11]) //filled | |
| 737 | { | ||
| 738 | |||
| 739 | ✗ | if(sdci[12]/10000<128) //translucent | |
| 740 | { | ||
| 741 | ✗ | clear_bitmap(prim_bmp); | |
| 742 | ✗ | ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 743 | ✗ | rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 744 | ✗ | draw_trans_sprite(bmp, prim_bmp, 0, 0); | |
| 745 | } | ||
| 746 | else // no opacity | ||
| 747 | { | ||
| 748 | ✗ | ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 749 | ✗ | rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 750 | } | ||
| 751 | } | ||
| 752 | else //not filled | ||
| 753 | { | ||
| 754 | ✗ | if(sdci[12]/10000<128) //translucent | |
| 755 | { | ||
| 756 | ✗ | clear_bitmap(prim_bmp); | |
| 757 | ✗ | ellipse(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 758 | ✗ | rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 759 | ✗ | draw_trans_sprite(bmp, prim_bmp, 0, 0); | |
| 760 | } | ||
| 761 | else // no opacity | ||
| 762 | { | ||
| 763 | ✗ | ellipse(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 764 | ✗ | rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 765 | } | ||
| 766 | } | ||
| 767 | |||
| 768 | // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0. | ||
| 769 | // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around | ||
| 770 | // the ellipse, but it shouldn't be used anyway. | ||
| 771 | ✗ | if(color==0) | |
| 772 | { | ||
| 773 | // This is very slow, so check the smallest possible square | ||
| 774 | ✗ | int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady)); | |
| 775 | ✗ | int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady)); | |
| 776 | |||
| 777 | ✗ | for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++) | |
| 778 | ✗ | for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++) | |
| 779 | ✗ | if(getpixel(bmp, x, y)==255) | |
| 780 | ✗ | putpixel(bmp, x, y, 0); | |
| 781 | } | ||
| 782 | |||
| 783 | ✗ | script_drawing_commands.ReleaseSubBitmap(bitty); | |
| 784 | } | ||
| 785 | |||
| 786 | |||
| 787 | ✗ | void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 788 | { | ||
| 789 | //sdci[1]=layer | ||
| 790 | //sdci[2]=x | ||
| 791 | //sdci[3]=y | ||
| 792 | //sdci[4]=x2 | ||
| 793 | //sdci[5]=y2 | ||
| 794 | //sdci[6]=color | ||
| 795 | //sdci[7]=scale factor | ||
| 796 | //sdci[8]=rotation anchor x | ||
| 797 | //sdci[9]=rotation anchor y | ||
| 798 | //sdci[10]=rotation angle | ||
| 799 | //sdci[11]=opacity | ||
| 800 | ✗ | if(sdci[7]==0) //scale | |
| 801 | { | ||
| 802 | ✗ | return; | |
| 803 | } | ||
| 804 | |||
| 805 | ✗ | int32_t x1=sdci[2]/10000; | |
| 806 | ✗ | int32_t y1=sdci[3]/10000; | |
| 807 | ✗ | int32_t x2=sdci[4]/10000; | |
| 808 | ✗ | int32_t y2=sdci[5]/10000; | |
| 809 | |||
| 810 | ✗ | if(sdci[7] != 10000) | |
| 811 | { | ||
| 812 | ✗ | int32_t w=x2-x1+1; | |
| 813 | ✗ | int32_t h=y2-y1+1; | |
| 814 | ✗ | int32_t w2=int32_t(w*((double)sdci[7]/10000.0)); | |
| 815 | ✗ | int32_t h2=int32_t(h*((double)sdci[7]/10000.0)); | |
| 816 | ✗ | x1=x1-((w2-w)/2); | |
| 817 | ✗ | x2=x2+((w2-w)/2); | |
| 818 | ✗ | y1=y1-((h2-h)/2); | |
| 819 | ✗ | y2=y2+((h2-h)/2); | |
| 820 | } | ||
| 821 | |||
| 822 | ✗ | int32_t color=sdci[6]/10000; | |
| 823 | |||
| 824 | ✗ | if(sdci[11]/10000<=127) //translucent | |
| 825 | { | ||
| 826 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 827 | } | ||
| 828 | |||
| 829 | ✗ | if(sdci[10]!=0) //rotation | |
| 830 | { | ||
| 831 | int32_t xy[4]; | ||
| 832 | ✗ | int32_t rx=sdci[8]/10000; | |
| 833 | ✗ | int32_t ry=sdci[9]/10000; | |
| 834 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 835 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 836 | ✗ | fixed ra=ra1+ra2; | |
| 837 | |||
| 838 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 839 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 840 | ✗ | xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2 | |
| 841 | ✗ | xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2 | |
| 842 | ✗ | x1=xy[0]; | |
| 843 | ✗ | y1=xy[1]; | |
| 844 | ✗ | x2=xy[2]; | |
| 845 | ✗ | y2=xy[3]; | |
| 846 | } | ||
| 847 | |||
| 848 | ✗ | line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 849 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 850 | } | ||
| 851 | |||
| 852 | ✗ | void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 853 | { | ||
| 854 | //sdci[1]=layer | ||
| 855 | //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity } | ||
| 856 | |||
| 857 | //sdci[2]=x | ||
| 858 | //sdci[3]=y | ||
| 859 | //sdci[4]=x2 | ||
| 860 | //sdci[5]=y2 | ||
| 861 | //sdci[6]=color | ||
| 862 | //sdci[7]=scale factor | ||
| 863 | //sdci[8]=rotation anchor x | ||
| 864 | //sdci[9]=rotation anchor y | ||
| 865 | //sdci[10]=rotation angle | ||
| 866 | //sdci[11]=opacity | ||
| 867 | //if(sdci[7]==0) //scale | ||
| 868 | //{ | ||
| 869 | // return; | ||
| 870 | //} | ||
| 871 | |||
| 872 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 873 | |||
| 874 | ✗ | if(!v_ptr) | |
| 875 | { | ||
| 876 | ✗ | al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n"); | |
| 877 | ✗ | return; | |
| 878 | } | ||
| 879 | |||
| 880 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 881 | |||
| 882 | ✗ | if(v.empty()) | |
| 883 | ✗ | return; | |
| 884 | //Z_scripterrlog("PutPixels reached line %d\n", 983); | ||
| 885 | |||
| 886 | ✗ | int32_t* pos = &v[0]; | |
| 887 | ✗ | int32_t sz = v.size(); | |
| 888 | |||
| 889 | ✗ | for ( int32_t q = 0; q < sz; q+=10 ) | |
| 890 | { | ||
| 891 | |||
| 892 | ✗ | int32_t x1 = v.at(q); | |
| 893 | ✗ | Z_scripterrlog("Lines( x1 ) is: %d\n", x1); | |
| 894 | ✗ | int32_t y1 = v.at(q+1); | |
| 895 | ✗ | Z_scripterrlog("Lines( x2 ) is: %d\n", y1); | |
| 896 | ✗ | int32_t x2 = v.at(q+2); | |
| 897 | ✗ | Z_scripterrlog("Lines( x2 ) is: %d\n", x2); | |
| 898 | ✗ | int32_t y2 = v.at(q+3); | |
| 899 | ✗ | Z_scripterrlog("Lines( y2 ) is: %d\n", y2); | |
| 900 | ✗ | int32_t color = v.at(q+4); | |
| 901 | ✗ | Z_scripterrlog("Lines( colour ) is: %d\n", color); | |
| 902 | ✗ | Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5)); | |
| 903 | ✗ | if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale | |
| 904 | |||
| 905 | ✗ | if( v.at(q+5) != 10000) | |
| 906 | { | ||
| 907 | ✗ | int32_t w=x2-x1+1; | |
| 908 | ✗ | int32_t h=y2-y1+1; | |
| 909 | ✗ | int32_t w2=int32_t(w*((double)v.at(q+5))); | |
| 910 | ✗ | int32_t h2=int32_t(h*((double)v.at(q+5))); | |
| 911 | ✗ | x1=x1-((w2-w)/2); | |
| 912 | ✗ | x2=x2+((w2-w)/2); | |
| 913 | ✗ | y1=y1-((h2-h)/2); | |
| 914 | ✗ | y2=y2+((h2-h)/2); | |
| 915 | } | ||
| 916 | |||
| 917 | |||
| 918 | ✗ | Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9)); | |
| 919 | ✗ | if(v.at(q+9) <= 127) //translucent | |
| 920 | { | ||
| 921 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 922 | } | ||
| 923 | ✗ | else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 924 | ✗ | Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8)); | |
| 925 | ✗ | Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6)); | |
| 926 | ✗ | Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7)); | |
| 927 | ✗ | if( v.at(q+8) !=0 ) //rotation | |
| 928 | { | ||
| 929 | int32_t xy[4]; | ||
| 930 | |||
| 931 | ✗ | int32_t rx = v.at(q+6); | |
| 932 | |||
| 933 | ✗ | int32_t ry = v.at(q+7); | |
| 934 | |||
| 935 | ✗ | fixed ra1=itofix(v.at(q+8) % 1); | |
| 936 | ✗ | fixed ra2=itofix(v.at(q+8)); | |
| 937 | ✗ | fixed ra=ra1+ra2; | |
| 938 | |||
| 939 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 940 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 941 | ✗ | xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2 | |
| 942 | ✗ | xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2 | |
| 943 | ✗ | x1=xy[0]; | |
| 944 | ✗ | y1=xy[1]; | |
| 945 | ✗ | x2=xy[2]; | |
| 946 | ✗ | y2=xy[3]; | |
| 947 | } | ||
| 948 | ✗ | Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset); | |
| 949 | ✗ | Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset); | |
| 950 | ✗ | line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 951 | } | ||
| 952 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 953 | } | ||
| 954 | |||
| 955 | ✗ | void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 956 | { | ||
| 957 | //sdci[1]=layer | ||
| 958 | //sdci[2]=point count | ||
| 959 | //sdci[3]array[] | ||
| 960 | //sdci[4] = colour | ||
| 961 | //sdci[5] = opacity | ||
| 962 | |||
| 963 | ✗ | int32_t col = sdci[4]/10000; | |
| 964 | ✗ | int32_t op = sdci[5]/10000; | |
| 965 | |||
| 966 | //bool brokenOffset= ( (get_bit(extra_rules, er_BITMAPOFFSET)!=0) || (get_bit(quest_rules,qr_BITMAPOFFSETFIX)!=0) ); | ||
| 967 | //Z_scripterrlog("Broken offset rule for Polygon() is: %s\n", brokenOffset ? "ON" : "OFF"); | ||
| 968 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 969 | |||
| 970 | ✗ | if(!v_ptr) | |
| 971 | { | ||
| 972 | ✗ | al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n"); | |
| 973 | ✗ | return; | |
| 974 | } | ||
| 975 | |||
| 976 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 977 | |||
| 978 | ✗ | if(v.empty()) | |
| 979 | ✗ | return; | |
| 980 | //Z_scripterrlog("PutPixels reached line %d\n", 983); | ||
| 981 | |||
| 982 | ✗ | int32_t* pos = &v[0]; | |
| 983 | ✗ | int32_t sz = v.size(); | |
| 984 | ✗ | int32_t numpoints = (sdci[2]/10000); | |
| 985 | ✗ | if(sz & 1) --sz; //even amount only | |
| 986 | ✗ | if(numpoints > sz/2) //cap to array | |
| 987 | ✗ | numpoints = sz/2; | |
| 988 | ✗ | if(numpoints < 1) | |
| 989 | ✗ | return; //Don't draw 0 or negative point count | |
| 990 | |||
| 991 | //Fix the draw Y offset. -Z 20th June, 2019 | ||
| 992 | ✗ | for ( int32_t q = 1; q < sz; q+=2 ) | |
| 993 | { | ||
| 994 | ✗ | pos[q] += yoffset; | |
| 995 | } | ||
| 996 | ✗ | if(op <= 127) //translucent | |
| 997 | { | ||
| 998 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 999 | } | ||
| 1000 | ✗ | else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1001 | |||
| 1002 | ✗ | polygon(bmp, numpoints, (int32_t*)pos, col); | |
| 1003 | //polygon(bmp, (sdci[2]/10000), &v, col); | ||
| 1004 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1005 | } | ||
| 1006 | |||
| 1007 | ✗ | void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1008 | { | ||
| 1009 | //sdci[1]=layer | ||
| 1010 | //sdci[2]=point count | ||
| 1011 | //sdci[3]array[] | ||
| 1012 | //sdci[4] = colour | ||
| 1013 | //sdci[5] = opacity | ||
| 1014 | |||
| 1015 | ✗ | int32_t col = sdci[4]/10000; | |
| 1016 | ✗ | int32_t op = sdci[5]/10000; | |
| 1017 | |||
| 1018 | ✗ | if ( sdci[17] <= 0 ) | |
| 1019 | { | ||
| 1020 | ✗ | Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 1021 | ✗ | return; | |
| 1022 | } | ||
| 1023 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 1024 | ✗ | if ( refbmp == NULL ) return; | |
| 1025 | |||
| 1026 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 1027 | |||
| 1028 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 1029 | |||
| 1030 | ✗ | if(!v_ptr) | |
| 1031 | { | ||
| 1032 | ✗ | al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n"); | |
| 1033 | ✗ | return; | |
| 1034 | } | ||
| 1035 | |||
| 1036 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 1037 | |||
| 1038 | ✗ | if(v.empty()) | |
| 1039 | ✗ | return; | |
| 1040 | //Z_scripterrlog("PutPixels reached line %d\n", 983); | ||
| 1041 | |||
| 1042 | ✗ | int32_t* pos = &v[0]; | |
| 1043 | ✗ | int32_t sz = v.size(); | |
| 1044 | ✗ | int32_t numpoints = (sdci[2]/10000); | |
| 1045 | ✗ | if(sz & 1) --sz; //even amount only | |
| 1046 | ✗ | if(numpoints > sz/2) //cap to array | |
| 1047 | ✗ | numpoints = sz/2; | |
| 1048 | ✗ | if(numpoints < 1) | |
| 1049 | ✗ | return; //Don't draw 0 or negative point count | |
| 1050 | |||
| 1051 | //Fix the draw Y offset. -Z 20th June, 2019 | ||
| 1052 | ✗ | for ( int32_t q = 1; q < sz; q+=2 ) | |
| 1053 | { | ||
| 1054 | ✗ | pos[q] += yoffset; | |
| 1055 | } | ||
| 1056 | ✗ | if(op <= 127) //translucent | |
| 1057 | { | ||
| 1058 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 1059 | } | ||
| 1060 | ✗ | else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1061 | |||
| 1062 | ✗ | polygon(refbmp, numpoints, (int32_t*)pos, col); | |
| 1063 | //polygon(refbmp, (sdci[2]/10000), &v, col); | ||
| 1064 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1065 | } | ||
| 1066 | |||
| 1067 | ✗ | void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1068 | { | ||
| 1069 | /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */ | ||
| 1070 | |||
| 1071 | ✗ | int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000), | |
| 1072 | ✗ | xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000), | |
| 1073 | ✗ | xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000), | |
| 1074 | ✗ | xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000) | |
| 1075 | }; | ||
| 1076 | |||
| 1077 | ✗ | if(sdci[11]/10000 < 128) //translucent | |
| 1078 | { | ||
| 1079 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 1080 | } | ||
| 1081 | |||
| 1082 | ✗ | spline(bmp, points, sdci[10]/10000); | |
| 1083 | |||
| 1084 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1085 | } | ||
| 1086 | |||
| 1087 | |||
| 1088 | ✗ | void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1089 | { | ||
| 1090 | //sdci[1]=layer | ||
| 1091 | //sdci[2]=x | ||
| 1092 | //sdci[3]=y | ||
| 1093 | //sdci[4]=color | ||
| 1094 | //sdci[5]=rotation anchor x | ||
| 1095 | //sdci[6]=rotation anchor y | ||
| 1096 | //sdci[7]=rotation angle | ||
| 1097 | //sdci[8]=opacity | ||
| 1098 | ✗ | int32_t x1=sdci[2]/10000; | |
| 1099 | ✗ | int32_t y1=sdci[3]/10000; | |
| 1100 | ✗ | int32_t color=sdci[4]/10000; | |
| 1101 | |||
| 1102 | ✗ | if(sdci[8]/10000<=127) //translucent | |
| 1103 | { | ||
| 1104 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 1105 | } | ||
| 1106 | |||
| 1107 | ✗ | if(sdci[7]!=0) //rotation | |
| 1108 | { | ||
| 1109 | int32_t xy[2]; | ||
| 1110 | ✗ | int32_t rx=sdci[5]/10000; | |
| 1111 | ✗ | int32_t ry=sdci[6]/10000; | |
| 1112 | ✗ | fixed ra1=itofix(sdci[7]%10000)/10000; | |
| 1113 | ✗ | fixed ra2=itofix(sdci[7]/10000); | |
| 1114 | ✗ | fixed ra=ra1+ra2; | |
| 1115 | |||
| 1116 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 1117 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 1118 | ✗ | x1=xy[0]; | |
| 1119 | ✗ | y1=xy[1]; | |
| 1120 | } | ||
| 1121 | |||
| 1122 | ✗ | putpixel(bmp, x1+xoffset, y1+yoffset, color); | |
| 1123 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1124 | } | ||
| 1125 | |||
| 1126 | ✗ | void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1127 | { | ||
| 1128 | //Z_scripterrlog("Starting putpixels()%s\n"); | ||
| 1129 | //sdci[1]=layer | ||
| 1130 | //sdci[2]=array {x,y,colour,opacity} | ||
| 1131 | //sdci[3]=rotation anchor x | ||
| 1132 | //sdci[4]=rotation anchor y | ||
| 1133 | //sdci[5]=rotation angle | ||
| 1134 | |||
| 1135 | |||
| 1136 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 1137 | |||
| 1138 | ✗ | if(!v_ptr) | |
| 1139 | { | ||
| 1140 | ✗ | al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n"); | |
| 1141 | ✗ | return; | |
| 1142 | } | ||
| 1143 | |||
| 1144 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 1145 | |||
| 1146 | ✗ | if(v.empty()) | |
| 1147 | ✗ | return; | |
| 1148 | //Z_scripterrlog("PutPixels reached line %d\n", 983); | ||
| 1149 | |||
| 1150 | ✗ | int32_t* pos = &v[0]; | |
| 1151 | ✗ | int32_t sz = v.size(); | |
| 1152 | //Z_scripterrlog("Vector size is: %d\n", sz); | ||
| 1153 | //for ( int32_t m = 0; m < 256; ++m ) Z_scripterrlog("Vector contents at pos[%d]: %d\n", m, pos[m]); | ||
| 1154 | |||
| 1155 | //FFCore.getValues(sdci[2]/10000, points, sz); | ||
| 1156 | |||
| 1157 | |||
| 1158 | ✗ | int32_t x1 = 0; | |
| 1159 | ✗ | int32_t y1 = 0; | |
| 1160 | |||
| 1161 | ✗ | for ( int32_t q = 0; q < sz; q+=4 ) | |
| 1162 | { | ||
| 1163 | //Z_scripterrlog("Vector q: %d\n", q); | ||
| 1164 | //if ( q > sz-1 ) break; | ||
| 1165 | ✗ | x1 = v.at(q); //pos[q]; | |
| 1166 | ✗ | y1 = v.at(q+1); //pos[q+1]; | |
| 1167 | //Z_scripterrlog("x1 is: %d\n", x1); | ||
| 1168 | //Z_scripterrlog("y1 is: %d\n", 1); | ||
| 1169 | ✗ | if(sdci[5]!=0) //rotation | |
| 1170 | { | ||
| 1171 | int32_t xy[2]; | ||
| 1172 | ✗ | int32_t rx=sdci[3]/10000; | |
| 1173 | ✗ | int32_t ry=sdci[4]/10000; | |
| 1174 | ✗ | fixed ra1=itofix(sdci[5]%10000)/10000; | |
| 1175 | ✗ | fixed ra2=itofix(sdci[5]/10000); | |
| 1176 | ✗ | fixed ra=ra1+ra2; | |
| 1177 | |||
| 1178 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 1179 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 1180 | ✗ | x1=xy[0]; | |
| 1181 | ✗ | y1=xy[1]; | |
| 1182 | } | ||
| 1183 | //Z_scripterrlog("PutPixels()%s value is %d\n","x",x1); | ||
| 1184 | //Z_scripterrlog("PutPixels()%s value is %d\n","y",y1); | ||
| 1185 | //Z_scripterrlog("PutPixels()%s value is %d\n","colour",points[q+2]); | ||
| 1186 | ✗ | if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 1187 | ✗ | else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1188 | ✗ | putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/); | |
| 1189 | //if ( points[q+3] < 128 ) | ||
| 1190 | |||
| 1191 | //else drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | ||
| 1192 | } | ||
| 1193 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 1194 | } | ||
| 1195 | |||
| 1196 | ✗ | void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1197 | { | ||
| 1198 | //sdci[1]=layer | ||
| 1199 | //sdci[2]=x | ||
| 1200 | //sdci[3]=y | ||
| 1201 | //sdci[4]=tile | ||
| 1202 | //sdci[5]=tile width | ||
| 1203 | //sdci[6]=tile height | ||
| 1204 | //sdci[7]=color (cset) | ||
| 1205 | //sdci[8]=scale x | ||
| 1206 | //sdci[9]=scale y | ||
| 1207 | //sdci[10]=rotation anchor x | ||
| 1208 | //sdci[11]=rotation anchor y | ||
| 1209 | //sdci[12]=rotation angle | ||
| 1210 | //sdci[13]=flip | ||
| 1211 | //sdci[14]=transparency | ||
| 1212 | //sdci[15]=opacity | ||
| 1213 | |||
| 1214 | ✗ | int32_t w = sdci[5]/10000; | |
| 1215 | ✗ | int32_t h = sdci[6]/10000; | |
| 1216 | |||
| 1217 | ✗ | if(w < 1 || h < 1 || h > 20 || w > 20) | |
| 1218 | { | ||
| 1219 | ✗ | return; | |
| 1220 | } | ||
| 1221 | |||
| 1222 | ✗ | int32_t xscale=sdci[8]/10000; | |
| 1223 | ✗ | int32_t yscale=sdci[9]/10000; | |
| 1224 | ✗ | int32_t rx = sdci[10]/10000; | |
| 1225 | ✗ | int32_t ry = sdci[11]/10000; | |
| 1226 | ✗ | float rotation=sdci[12]/10000; | |
| 1227 | ✗ | int32_t flip=(sdci[13]/10000)&3; | |
| 1228 | ✗ | bool transparency=sdci[14]!=0; | |
| 1229 | ✗ | int32_t opacity=sdci[15]/10000; | |
| 1230 | ✗ | int32_t color=sdci[7]/10000; | |
| 1231 | |||
| 1232 | ✗ | int32_t x1=sdci[2]/10000; | |
| 1233 | ✗ | int32_t y1=sdci[3]/10000; | |
| 1234 | |||
| 1235 | //don't scale if it's not safe to do so | ||
| 1236 | ✗ | bool canscale = true; | |
| 1237 | |||
| 1238 | ✗ | if(xscale==0||yscale==0) | |
| 1239 | { | ||
| 1240 | ✗ | return; | |
| 1241 | } | ||
| 1242 | |||
| 1243 | ✗ | if(xscale<0||yscale<0) | |
| 1244 | ✗ | canscale = false; //default size | |
| 1245 | |||
| 1246 | ✗ | if((xscale>0 && yscale>0) || rotation) //scaled or rotated | |
| 1247 | { | ||
| 1248 | ✗ | BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); | |
| 1249 | |||
| 1250 | ✗ | if(transparency) //transparency | |
| 1251 | { | ||
| 1252 | ✗ | TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip); | |
| 1253 | } | ||
| 1254 | else //no transparency | ||
| 1255 | { | ||
| 1256 | ✗ | TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip); | |
| 1257 | } | ||
| 1258 | |||
| 1259 | ✗ | if(rotation != 0) | |
| 1260 | { | ||
| 1261 | //low negative values indicate no anchor-point rotation | ||
| 1262 | ✗ | if(rx>-777||ry>-777) | |
| 1263 | { | ||
| 1264 | int32_t xy[2]; | ||
| 1265 | ✗ | fixed ra1=itofix(sdci[12]%10000)/10000; | |
| 1266 | ✗ | fixed ra2=itofix(sdci[12]/10000); | |
| 1267 | ✗ | fixed ra=ra1+ra2; | |
| 1268 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 1269 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 1270 | ✗ | x1=xy[0]; | |
| 1271 | ✗ | y1=xy[1]; | |
| 1272 | } | ||
| 1273 | |||
| 1274 | ✗ | if(canscale) //scale first | |
| 1275 | { | ||
| 1276 | //damnit all, .. fixme. | ||
| 1277 | ✗ | BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale); | |
| 1278 | ✗ | clear_bitmap(tempbit); | |
| 1279 | |||
| 1280 | ✗ | stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale); | |
| 1281 | |||
| 1282 | ✗ | if(opacity < 128) | |
| 1283 | { | ||
| 1284 | ✗ | clear_bitmap(prim_bmp); | |
| 1285 | ✗ | rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation)); | |
| 1286 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1287 | } | ||
| 1288 | else | ||
| 1289 | { | ||
| 1290 | ✗ | rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 1291 | } | ||
| 1292 | |||
| 1293 | ✗ | destroy_bitmap(tempbit); | |
| 1294 | } | ||
| 1295 | else //no scale | ||
| 1296 | { | ||
| 1297 | ✗ | if(opacity < 128) | |
| 1298 | { | ||
| 1299 | ✗ | clear_bitmap(prim_bmp); | |
| 1300 | ✗ | rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation)); | |
| 1301 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1302 | } | ||
| 1303 | else | ||
| 1304 | { | ||
| 1305 | ✗ | rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 1306 | } | ||
| 1307 | } | ||
| 1308 | } | ||
| 1309 | else //scale only | ||
| 1310 | { | ||
| 1311 | ✗ | if(canscale) | |
| 1312 | { | ||
| 1313 | ✗ | if(opacity<128) | |
| 1314 | { | ||
| 1315 | ✗ | clear_bitmap(prim_bmp); | |
| 1316 | ✗ | stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale); | |
| 1317 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1318 | } | ||
| 1319 | else | ||
| 1320 | { | ||
| 1321 | ✗ | stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale); | |
| 1322 | } | ||
| 1323 | } | ||
| 1324 | else //error -do not scale | ||
| 1325 | { | ||
| 1326 | ✗ | if(opacity<128) | |
| 1327 | { | ||
| 1328 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1329 | } | ||
| 1330 | else | ||
| 1331 | { | ||
| 1332 | ✗ | draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset); | |
| 1333 | } | ||
| 1334 | } | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbitty); | |
| 1338 | |||
| 1339 | } | ||
| 1340 | else // no scale or rotation | ||
| 1341 | { | ||
| 1342 | ✗ | if(transparency) | |
| 1343 | { | ||
| 1344 | ✗ | if(opacity<=127) | |
| 1345 | ✗ | TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity); | |
| 1346 | else | ||
| 1347 | ✗ | TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip); | |
| 1348 | } | ||
| 1349 | else | ||
| 1350 | { | ||
| 1351 | ✗ | if(opacity<=127) | |
| 1352 | ✗ | TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity); | |
| 1353 | else | ||
| 1354 | ✗ | TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip); | |
| 1355 | } | ||
| 1356 | } | ||
| 1357 | } | ||
| 1358 | |||
| 1359 | ✗ | void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1360 | { | ||
| 1361 | //sdci[1]=layer | ||
| 1362 | //sdci[2]=x | ||
| 1363 | //sdci[3]=y | ||
| 1364 | //sdci[4]=tile | ||
| 1365 | //sdci[5]=tile width | ||
| 1366 | //sdci[6]=tile height | ||
| 1367 | //sdci[7]=flip | ||
| 1368 | |||
| 1369 | ✗ | int32_t w = sdci[5]/10000; | |
| 1370 | ✗ | int32_t h = sdci[6]/10000; | |
| 1371 | |||
| 1372 | ✗ | if(w < 1 || h < 1 || h > 20 || w > 20) | |
| 1373 | { | ||
| 1374 | ✗ | return; | |
| 1375 | } | ||
| 1376 | |||
| 1377 | ✗ | int32_t flip=(sdci[7]/10000)&3; | |
| 1378 | |||
| 1379 | ✗ | int32_t x1=sdci[2]/10000; | |
| 1380 | ✗ | int32_t y1=sdci[3]/10000; | |
| 1381 | |||
| 1382 | ✗ | TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip); | |
| 1383 | } | ||
| 1384 | |||
| 1385 | |||
| 1386 | ✗ | void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1387 | { | ||
| 1388 | //sdci[1]=layer | ||
| 1389 | //sdci[2]=x | ||
| 1390 | //sdci[3]=y | ||
| 1391 | //sdci[4]=combo | ||
| 1392 | //sdci[5]=tile width | ||
| 1393 | //sdci[6]=tile height | ||
| 1394 | //sdci[7]=color (cset) | ||
| 1395 | //sdci[8]=scale x | ||
| 1396 | //sdci[9]=scale y | ||
| 1397 | //sdci[10]=rotation anchor x | ||
| 1398 | //sdci[11]=rotation anchor y | ||
| 1399 | //sdci[12]=rotation angle | ||
| 1400 | //sdci[13]=frame | ||
| 1401 | //sdci[14]=flip | ||
| 1402 | //sdci[15]=transparency | ||
| 1403 | //sdci[16]=opacity | ||
| 1404 | |||
| 1405 | ✗ | int32_t w = sdci[5]/10000; | |
| 1406 | ✗ | int32_t h = sdci[6]/10000; | |
| 1407 | |||
| 1408 | ✗ | if(w<1||h<1||h>20||w>20) | |
| 1409 | { | ||
| 1410 | ✗ | return; | |
| 1411 | } | ||
| 1412 | ✗ | int32_t cmb = (sdci[4]/10000); | |
| 1413 | ✗ | if((unsigned)cmb >= MAXCOMBOS) | |
| 1414 | { | ||
| 1415 | ✗ | Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 1416 | ✗ | return; | |
| 1417 | } | ||
| 1418 | |||
| 1419 | ✗ | int32_t xscale=sdci[8]/10000; | |
| 1420 | ✗ | int32_t yscale=sdci[9]/10000; | |
| 1421 | ✗ | int32_t rx = sdci[10]/10000; //these work now | |
| 1422 | ✗ | int32_t ry = sdci[11]/10000; //these work now | |
| 1423 | ✗ | float rotation=sdci[12]/10000; | |
| 1424 | |||
| 1425 | ✗ | bool transparency=sdci[15]!=0; | |
| 1426 | ✗ | int32_t opacity=sdci[16]/10000; | |
| 1427 | ✗ | int32_t color=sdci[7]/10000; | |
| 1428 | ✗ | int32_t x1=sdci[2]/10000; | |
| 1429 | ✗ | int32_t y1=sdci[3]/10000; | |
| 1430 | |||
| 1431 | ✗ | const newcombo & c = combobuf[cmb]; | |
| 1432 | ✗ | int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 1433 | ✗ | int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip; | |
| 1434 | ✗ | int32_t skiprows=c.skipanimy; | |
| 1435 | |||
| 1436 | |||
| 1437 | //don't scale if it's not safe to do so | ||
| 1438 | ✗ | bool canscale = true; | |
| 1439 | |||
| 1440 | ✗ | if(xscale==0||yscale==0) | |
| 1441 | { | ||
| 1442 | ✗ | return; | |
| 1443 | } | ||
| 1444 | |||
| 1445 | ✗ | if(xscale<0||yscale<0) | |
| 1446 | ✗ | canscale = false; //default size | |
| 1447 | |||
| 1448 | ✗ | if((xscale>0 && yscale>0) || rotation) //scaled or rotated | |
| 1449 | { | ||
| 1450 | ✗ | BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D | |
| 1451 | |||
| 1452 | ✗ | if(transparency) | |
| 1453 | { | ||
| 1454 | ✗ | TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows); | |
| 1455 | } | ||
| 1456 | else //no transparency | ||
| 1457 | { | ||
| 1458 | ✗ | TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows); | |
| 1459 | } | ||
| 1460 | |||
| 1461 | ✗ | if(rotation != 0) // rotate | |
| 1462 | { | ||
| 1463 | //fixed point sucks ;0 | ||
| 1464 | ✗ | if(rx>-777||ry>-777) //set the rotation anchor and rotate around that | |
| 1465 | { | ||
| 1466 | int32_t xy[2]; | ||
| 1467 | ✗ | fixed ra1=itofix(sdci[12]%10000)/10000; | |
| 1468 | ✗ | fixed ra2=itofix(sdci[12]/10000); | |
| 1469 | ✗ | fixed ra=ra1+ra2; | |
| 1470 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 1471 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 1472 | ✗ | x1=xy[0]; | |
| 1473 | ✗ | y1=xy[1]; | |
| 1474 | } | ||
| 1475 | |||
| 1476 | ✗ | if(canscale) //scale first | |
| 1477 | { | ||
| 1478 | ✗ | BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale); | |
| 1479 | ✗ | clear_bitmap(tempbit); | |
| 1480 | |||
| 1481 | ✗ | stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale); | |
| 1482 | |||
| 1483 | ✗ | if(opacity < 128) | |
| 1484 | { | ||
| 1485 | ✗ | clear_bitmap(prim_bmp); | |
| 1486 | ✗ | rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation)); | |
| 1487 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1488 | } | ||
| 1489 | else | ||
| 1490 | { | ||
| 1491 | ✗ | rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 1492 | } | ||
| 1493 | |||
| 1494 | ✗ | destroy_bitmap(tempbit); | |
| 1495 | } | ||
| 1496 | else //no scale | ||
| 1497 | { | ||
| 1498 | ✗ | if(opacity < 128) | |
| 1499 | { | ||
| 1500 | ✗ | clear_bitmap(prim_bmp); | |
| 1501 | ✗ | rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation)); | |
| 1502 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1503 | } | ||
| 1504 | else | ||
| 1505 | { | ||
| 1506 | ✗ | rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 1507 | } | ||
| 1508 | } | ||
| 1509 | } | ||
| 1510 | else //scale only | ||
| 1511 | { | ||
| 1512 | ✗ | if(canscale) | |
| 1513 | { | ||
| 1514 | ✗ | if(opacity<128) | |
| 1515 | { | ||
| 1516 | ✗ | clear_bitmap(prim_bmp); | |
| 1517 | ✗ | stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale); | |
| 1518 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1519 | } | ||
| 1520 | else | ||
| 1521 | { | ||
| 1522 | ✗ | stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale); | |
| 1523 | } | ||
| 1524 | } | ||
| 1525 | else //error -do not scale | ||
| 1526 | { | ||
| 1527 | ✗ | if(opacity<128) | |
| 1528 | { | ||
| 1529 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 1530 | } | ||
| 1531 | else | ||
| 1532 | { | ||
| 1533 | ✗ | draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset); | |
| 1534 | } | ||
| 1535 | } | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks | |
| 1539 | } | ||
| 1540 | else // no scale or rotation | ||
| 1541 | { | ||
| 1542 | ✗ | if(transparency) | |
| 1543 | { | ||
| 1544 | ✗ | if(opacity<=127) | |
| 1545 | ✗ | TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows); | |
| 1546 | else | ||
| 1547 | ✗ | TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows); | |
| 1548 | } | ||
| 1549 | else | ||
| 1550 | { | ||
| 1551 | ✗ | if(opacity<=127) | |
| 1552 | ✗ | TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows); | |
| 1553 | else | ||
| 1554 | ✗ | TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows); | |
| 1555 | } | ||
| 1556 | } | ||
| 1557 | } | ||
| 1558 | |||
| 1559 | ✗ | void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1560 | { | ||
| 1561 | //sdci[1]=layer | ||
| 1562 | //sdci[2]=x | ||
| 1563 | //sdci[3]=y | ||
| 1564 | //sdci[4]=combo | ||
| 1565 | //sdci[5]=tile width | ||
| 1566 | //sdci[6]=tile height | ||
| 1567 | //sdci[7]=flip | ||
| 1568 | |||
| 1569 | ✗ | int32_t w = sdci[5]/10000; | |
| 1570 | ✗ | int32_t h = sdci[6]/10000; | |
| 1571 | |||
| 1572 | ✗ | if(w<1||h<1||h>20||w>20) | |
| 1573 | { | ||
| 1574 | ✗ | return; | |
| 1575 | } | ||
| 1576 | ✗ | int32_t cmb = (sdci[4]/10000); | |
| 1577 | ✗ | if((unsigned)cmb >= MAXCOMBOS) | |
| 1578 | { | ||
| 1579 | ✗ | Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 1580 | ✗ | return; | |
| 1581 | } | ||
| 1582 | |||
| 1583 | ✗ | int32_t x1=sdci[2]/10000; | |
| 1584 | ✗ | int32_t y1=sdci[3]/10000; | |
| 1585 | |||
| 1586 | ✗ | const newcombo & c = combobuf[cmb]; | |
| 1587 | ✗ | int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 1588 | ✗ | int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip; | |
| 1589 | ✗ | int32_t skiprows=c.skipanimy; | |
| 1590 | |||
| 1591 | ✗ | TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows); | |
| 1592 | } | ||
| 1593 | |||
| 1594 | |||
| 1595 | ✗ | void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1596 | { | ||
| 1597 | /* layer, x, y, tile, color opacity */ | ||
| 1598 | |||
| 1599 | ✗ | int32_t opacity = sdci[6]/10000; | |
| 1600 | |||
| 1601 | ✗ | if(opacity < 128) | |
| 1602 | ✗ | overtiletranslucent16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity); | |
| 1603 | else | ||
| 1604 | ✗ | overtile16(bmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0); | |
| 1605 | } | ||
| 1606 | |||
| 1607 | ✗ | void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1608 | { | ||
| 1609 | /* layer, x, y, tile, color opacity */ | ||
| 1610 | |||
| 1611 | //sdci[1]=layer | ||
| 1612 | //sdci[2]=array {x,y,tile,colour,opacity} | ||
| 1613 | |||
| 1614 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 1615 | |||
| 1616 | ✗ | if(!v_ptr) | |
| 1617 | { | ||
| 1618 | ✗ | al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n"); | |
| 1619 | ✗ | return; | |
| 1620 | } | ||
| 1621 | |||
| 1622 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 1623 | |||
| 1624 | ✗ | if(v.empty()) | |
| 1625 | ✗ | return; | |
| 1626 | //Z_scripterrlog("PutPixels reached line %d\n", 983); | ||
| 1627 | |||
| 1628 | ✗ | int32_t* pos = &v[0]; | |
| 1629 | ✗ | int32_t sz = v.size(); | |
| 1630 | |||
| 1631 | ✗ | for ( int32_t q = 0; q < sz; q+=5 ) | |
| 1632 | { | ||
| 1633 | |||
| 1634 | ✗ | if(v.at(q+4) < 128) | |
| 1635 | ✗ | overtiletranslucent16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0, v.at(q+4)); | |
| 1636 | else | ||
| 1637 | ✗ | overtile16(bmp, v.at(q), xoffset+(v.at(q+1)), yoffset+(v.at(q+2)), v.at(q+3), 0); | |
| 1638 | } | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | |||
| 1642 | |||
| 1643 | 880 | void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1644 | { | ||
| 1645 | /* layer, x, y, tile, color opacity */ | ||
| 1646 | |||
| 1647 | 880 | int32_t opacity = sdci[6] / 10000; | |
| 1648 | 880 | int32_t x1 = sdci[2] / 10000; | |
| 1649 | 880 | int32_t y1 = sdci[3] / 10000; | |
| 1650 | |||
| 1651 | 880 | int32_t cmb = (sdci[4]/10000); | |
| 1652 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 880 times.
|
880 | if((unsigned)cmb >= MAXCOMBOS) |
| 1653 | { | ||
| 1654 | ✗ | Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 1655 | ✗ | return; | |
| 1656 | } | ||
| 1657 | //if( index >= MAXCOMBOS ) return; //bleh. | ||
| 1658 | /* | ||
| 1659 | const newcombo & c = combobuf[index]; | ||
| 1660 | |||
| 1661 | if(opacity < 128) | ||
| 1662 | overtiletranslucent16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity); | ||
| 1663 | else | ||
| 1664 | overtile16(bmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip); | ||
| 1665 | */ | ||
| 1666 | |||
| 1667 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 880 times.
|
880 | if(opacity < 128) |
| 1668 | { | ||
| 1669 | //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity) | ||
| 1670 | ✗ | overcomboblocktranslucent(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128); | |
| 1671 | |||
| 1672 | } | ||
| 1673 | else | ||
| 1674 | { | ||
| 1675 | //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h) | ||
| 1676 | 880 | overcomboblock(bmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1); | |
| 1677 | } | ||
| 1678 | 880 | } | |
| 1679 | |||
| 1680 | ✗ | void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1681 | { | ||
| 1682 | /* layer, x, y, combo, cset, opacity */ | ||
| 1683 | |||
| 1684 | //sdci[1]=layer | ||
| 1685 | //sdci[2]=array {x,y,combo,cset,opacity} | ||
| 1686 | |||
| 1687 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 1688 | |||
| 1689 | ✗ | if(!v_ptr) | |
| 1690 | { | ||
| 1691 | ✗ | al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n"); | |
| 1692 | ✗ | return; | |
| 1693 | } | ||
| 1694 | |||
| 1695 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 1696 | |||
| 1697 | ✗ | if(v.empty()) | |
| 1698 | ✗ | return; | |
| 1699 | |||
| 1700 | ✗ | int32_t* pos = &v[0]; | |
| 1701 | ✗ | int32_t sz = v.size(); | |
| 1702 | |||
| 1703 | ✗ | for ( int32_t q = 0; q < sz; q+=5 ) | |
| 1704 | { | ||
| 1705 | ✗ | if((unsigned)(v.at(q+2)) >= MAXCOMBOS) | |
| 1706 | { | ||
| 1707 | ✗ | Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2)); | |
| 1708 | ✗ | continue; | |
| 1709 | } | ||
| 1710 | ✗ | if(v.at(q+4) < 128) | |
| 1711 | { | ||
| 1712 | //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity) | ||
| 1713 | ✗ | overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128); | |
| 1714 | |||
| 1715 | } | ||
| 1716 | else | ||
| 1717 | { | ||
| 1718 | //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h) | ||
| 1719 | ✗ | overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1); | |
| 1720 | } | ||
| 1721 | } | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | |||
| 1725 | |||
| 1726 | |||
| 1727 | ✗ | void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1728 | { | ||
| 1729 | //broken 2.50.2 and earlier drawcharacter() | ||
| 1730 | ✗ | if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) ) | |
| 1731 | { | ||
| 1732 | //sdci[1]=layer | ||
| 1733 | //sdci[2]=x | ||
| 1734 | //sdci[3]=y | ||
| 1735 | //sdci[4]=font | ||
| 1736 | //sdci[5]=color | ||
| 1737 | //sdci[6]=bg color | ||
| 1738 | //sdci[7]=strech x (width) | ||
| 1739 | //sdci[8]=stretch y (height) | ||
| 1740 | //sdci[9]=char | ||
| 1741 | //sdci[10]=opacity | ||
| 1742 | |||
| 1743 | ✗ | int32_t x=sdci[2]/10000; | |
| 1744 | ✗ | int32_t y=sdci[3]/10000; | |
| 1745 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 1746 | ✗ | int32_t color=sdci[5]/10000; | |
| 1747 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 1748 | ✗ | int32_t w=sdci[7]/10000; | |
| 1749 | ✗ | int32_t h=sdci[8]/10000; | |
| 1750 | ✗ | char glyph=char(sdci[9]/10000); | |
| 1751 | ✗ | int32_t opacity=sdci[10]/10000; | |
| 1752 | |||
| 1753 | //safe check | ||
| 1754 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 1755 | |||
| 1756 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 1757 | |||
| 1758 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 1759 | |||
| 1760 | //undone | ||
| 1761 | ✗ | if(w>0&&h>0)//stretch the character | |
| 1762 | { | ||
| 1763 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 1764 | |||
| 1765 | ✗ | if(opacity < 128) | |
| 1766 | { | ||
| 1767 | ✗ | if(w>128||h>128) | |
| 1768 | { | ||
| 1769 | ✗ | clear_bitmap(prim_bmp); | |
| 1770 | |||
| 1771 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1772 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 1773 | ✗ | draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset); | |
| 1774 | } | ||
| 1775 | else //this is faster | ||
| 1776 | { | ||
| 1777 | ✗ | BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h); | |
| 1778 | |||
| 1779 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1780 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 1781 | ✗ | draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset); | |
| 1782 | |||
| 1783 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbmp2); | |
| 1784 | } | ||
| 1785 | } | ||
| 1786 | else // no opacity | ||
| 1787 | { | ||
| 1788 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1789 | ✗ | stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 1790 | } | ||
| 1791 | |||
| 1792 | } | ||
| 1793 | else //no stretch | ||
| 1794 | { | ||
| 1795 | ✗ | if(opacity < 128) | |
| 1796 | { | ||
| 1797 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 1798 | ✗ | clear_bitmap(pbmp); | |
| 1799 | |||
| 1800 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1801 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 1802 | |||
| 1803 | ✗ | destroy_bitmap(pbmp); | |
| 1804 | } | ||
| 1805 | else // no opacity | ||
| 1806 | { | ||
| 1807 | ✗ | textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph); | |
| 1808 | } | ||
| 1809 | } | ||
| 1810 | } | ||
| 1811 | |||
| 1812 | else //2.53.0 fixed version and later. | ||
| 1813 | { | ||
| 1814 | |||
| 1815 | //sdci[1]=layer | ||
| 1816 | //sdci[2]=x | ||
| 1817 | //sdci[3]=y | ||
| 1818 | //sdci[4]=font | ||
| 1819 | //sdci[5]=color | ||
| 1820 | //sdci[6]=bg color | ||
| 1821 | //sdci[7]=strech x (width) | ||
| 1822 | //sdci[8]=stretch y (height) | ||
| 1823 | //sdci[9]=char | ||
| 1824 | //sdci[10]=opacity | ||
| 1825 | |||
| 1826 | ✗ | int32_t x=sdci[2]/10000; | |
| 1827 | ✗ | int32_t y=sdci[3]/10000; | |
| 1828 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 1829 | ✗ | int32_t color=sdci[5]/10000; | |
| 1830 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 1831 | ✗ | int32_t w=sdci[7]/10000; | |
| 1832 | ✗ | int32_t h=sdci[8]/10000; | |
| 1833 | ✗ | char glyph=char(sdci[9]/10000); | |
| 1834 | ✗ | int32_t opacity=sdci[10]/10000; | |
| 1835 | |||
| 1836 | //safe check | ||
| 1837 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 1838 | |||
| 1839 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 1840 | |||
| 1841 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 1842 | |||
| 1843 | //undone | ||
| 1844 | ✗ | if(w>0&&h>0)//stretch the character | |
| 1845 | { | ||
| 1846 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 1847 | |||
| 1848 | ✗ | if(opacity < 128) | |
| 1849 | { | ||
| 1850 | ✗ | if(w>128||h>128) | |
| 1851 | { | ||
| 1852 | ✗ | clear_bitmap(prim_bmp); | |
| 1853 | |||
| 1854 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1855 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 1856 | ✗ | draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset); | |
| 1857 | } | ||
| 1858 | else //this is faster | ||
| 1859 | { | ||
| 1860 | ✗ | BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h); | |
| 1861 | |||
| 1862 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1863 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 1864 | ✗ | draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset); | |
| 1865 | |||
| 1866 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbmp2); | |
| 1867 | } | ||
| 1868 | } | ||
| 1869 | else // no opacity | ||
| 1870 | { | ||
| 1871 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1872 | ✗ | stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 1873 | } | ||
| 1874 | |||
| 1875 | } | ||
| 1876 | else //no stretch | ||
| 1877 | { | ||
| 1878 | ✗ | if(opacity < 128) | |
| 1879 | { | ||
| 1880 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 1881 | ✗ | clear_bitmap(pbmp); | |
| 1882 | |||
| 1883 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 1884 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 1885 | |||
| 1886 | ✗ | destroy_bitmap(pbmp); | |
| 1887 | } | ||
| 1888 | else // no opacity | ||
| 1889 | { | ||
| 1890 | ✗ | textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph); | |
| 1891 | } | ||
| 1892 | } | ||
| 1893 | |||
| 1894 | } | ||
| 1895 | |||
| 1896 | } | ||
| 1897 | |||
| 1898 | |||
| 1899 | ✗ | void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 1900 | { | ||
| 1901 | //broken 2.50.2 and earlier drawinteger() | ||
| 1902 | ✗ | if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) ) | |
| 1903 | { | ||
| 1904 | //sdci[1]=layer | ||
| 1905 | //sdci[2]=x | ||
| 1906 | //sdci[3]=y | ||
| 1907 | //sdci[4]=font | ||
| 1908 | //sdci[5]=color | ||
| 1909 | //sdci[6]=bg color | ||
| 1910 | //sdci[7]=strech x (width) | ||
| 1911 | //sdci[8]=stretch y (height) | ||
| 1912 | //sdci[9]=integer | ||
| 1913 | //sdci[10]=num decimal places | ||
| 1914 | //sdci[11]=opacity | ||
| 1915 | |||
| 1916 | ✗ | int32_t x=sdci[2]/10000; | |
| 1917 | ✗ | int32_t y=sdci[3]/10000; | |
| 1918 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 1919 | ✗ | int32_t color=sdci[5]/10000; | |
| 1920 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 1921 | ✗ | int32_t w=sdci[7]/10000; | |
| 1922 | ✗ | int32_t h=sdci[8]/10000; | |
| 1923 | //float number=static_cast<float>(sdci[9])/10000.0f; | ||
| 1924 | ✗ | int32_t decplace=sdci[10]/10000; | |
| 1925 | ✗ | int32_t opacity=sdci[11]/10000; | |
| 1926 | |||
| 1927 | //safe check | ||
| 1928 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 1929 | |||
| 1930 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 1931 | |||
| 1932 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 1933 | |||
| 1934 | char numbuf[15]; | ||
| 1935 | |||
| 1936 | ✗ | switch(decplace) | |
| 1937 | { | ||
| 1938 | default: | ||
| 1939 | case 0: | ||
| 1940 | ✗ | sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was | |
| 1941 | ✗ | break; //reducing the value by -1, so 8.000 printed as '7'. -Z | |
| 1942 | |||
| 1943 | case 1: | ||
| 1944 | //sprintf(numbuf,"%.01f",number); | ||
| 1945 | ✗ | sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower? | |
| 1946 | ✗ | break; | |
| 1947 | |||
| 1948 | case 2: | ||
| 1949 | //sprintf(numbuf,"%.02f",number); | ||
| 1950 | ✗ | sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 1951 | ✗ | break; | |
| 1952 | |||
| 1953 | case 3: | ||
| 1954 | //sprintf(numbuf,"%.03f",number); | ||
| 1955 | ✗ | sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 1956 | ✗ | break; | |
| 1957 | |||
| 1958 | case 4: | ||
| 1959 | //sprintf(numbuf,"%.04f",number); | ||
| 1960 | ✗ | sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 1961 | ✗ | break; | |
| 1962 | } | ||
| 1963 | |||
| 1964 | ✗ | if(w>0&&h>0)//stretch | |
| 1965 | { | ||
| 1966 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 1967 | |||
| 1968 | ✗ | if(opacity < 128) | |
| 1969 | { | ||
| 1970 | ✗ | if(w>128||h>128) | |
| 1971 | { | ||
| 1972 | ✗ | clear_bitmap(prim_bmp); | |
| 1973 | |||
| 1974 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 1975 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 1976 | ✗ | draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset); | |
| 1977 | } | ||
| 1978 | else | ||
| 1979 | { | ||
| 1980 | ✗ | BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h); | |
| 1981 | ✗ | clear_bitmap(pbmp2); | |
| 1982 | |||
| 1983 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 1984 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 1985 | ✗ | draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset); | |
| 1986 | |||
| 1987 | ✗ | destroy_bitmap(pbmp2); | |
| 1988 | } | ||
| 1989 | } | ||
| 1990 | else // no opacity | ||
| 1991 | { | ||
| 1992 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 1993 | ✗ | stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 1994 | } | ||
| 1995 | |||
| 1996 | } | ||
| 1997 | else //no stretch | ||
| 1998 | { | ||
| 1999 | ✗ | if(opacity < 128) | |
| 2000 | { | ||
| 2001 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 2002 | ✗ | clear_bitmap(pbmp); | |
| 2003 | |||
| 2004 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 2005 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 2006 | |||
| 2007 | ✗ | destroy_bitmap(pbmp); | |
| 2008 | } | ||
| 2009 | else // no opacity | ||
| 2010 | { | ||
| 2011 | ✗ | textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color); | |
| 2012 | } | ||
| 2013 | } | ||
| 2014 | |||
| 2015 | } | ||
| 2016 | |||
| 2017 | else //2.53.0 fixed version and later. | ||
| 2018 | { | ||
| 2019 | //sdci[1]=layer | ||
| 2020 | //sdci[2]=x | ||
| 2021 | //sdci[3]=y | ||
| 2022 | //sdci[4]=font | ||
| 2023 | //sdci[5]=color | ||
| 2024 | //sdci[6]=bg color | ||
| 2025 | //sdci[7]=strech x (width) | ||
| 2026 | //sdci[8]=stretch y (height) | ||
| 2027 | //sdci[9]=integer | ||
| 2028 | //sdci[10]=num decimal places | ||
| 2029 | //sdci[11]=opacity | ||
| 2030 | |||
| 2031 | ✗ | int32_t x=sdci[2]/10000; | |
| 2032 | ✗ | int32_t y=sdci[3]/10000; | |
| 2033 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 2034 | ✗ | int32_t color=sdci[5]/10000; | |
| 2035 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 2036 | ✗ | int32_t w=sdci[7]/10000; | |
| 2037 | ✗ | int32_t h=sdci[8]/10000; | |
| 2038 | //float number=static_cast<float>(sdci[9])/10000.0f; | ||
| 2039 | //int32_t numberint = sdci[9]/10000; | ||
| 2040 | ✗ | int32_t decplace=sdci[10]/10000; | |
| 2041 | ✗ | int32_t opacity=sdci[11]/10000; | |
| 2042 | |||
| 2043 | //safe check | ||
| 2044 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 2045 | |||
| 2046 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 2047 | |||
| 2048 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 2049 | |||
| 2050 | char numbuf[15]; | ||
| 2051 | |||
| 2052 | ✗ | switch(decplace) | |
| 2053 | { | ||
| 2054 | default: | ||
| 2055 | case 0: | ||
| 2056 | ✗ | sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was | |
| 2057 | ✗ | break; //reducing the value by -1, so 8.000 printed as '7'. -Z | |
| 2058 | |||
| 2059 | case 1: | ||
| 2060 | //sprintf(numbuf,"%.01f",number); | ||
| 2061 | ✗ | sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower? | |
| 2062 | ✗ | break; | |
| 2063 | |||
| 2064 | case 2: | ||
| 2065 | //sprintf(numbuf,"%.02f",number); | ||
| 2066 | ✗ | sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 2067 | ✗ | break; | |
| 2068 | |||
| 2069 | case 3: | ||
| 2070 | //sprintf(numbuf,"%.03f",number); | ||
| 2071 | ✗ | sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 2072 | ✗ | break; | |
| 2073 | |||
| 2074 | case 4: | ||
| 2075 | //sprintf(numbuf,"%.04f",number); | ||
| 2076 | ✗ | sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 2077 | ✗ | break; | |
| 2078 | } | ||
| 2079 | |||
| 2080 | //FONT* font=get_zc_font(sdci[4]/10000); | ||
| 2081 | |||
| 2082 | ✗ | if(w>0&&h>0)//stretch | |
| 2083 | { | ||
| 2084 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index))); | |
| 2085 | ✗ | clear_bitmap(pbmp); | |
| 2086 | //script_drawing_commands.GetSmallTextureBitmap(1,1); | ||
| 2087 | |||
| 2088 | ✗ | if(opacity < 128) | |
| 2089 | { | ||
| 2090 | ✗ | if(w>128||h>128) | |
| 2091 | { | ||
| 2092 | ✗ | clear_bitmap(prim_bmp); | |
| 2093 | |||
| 2094 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 2095 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 2096 | ✗ | draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset); | |
| 2097 | } | ||
| 2098 | else | ||
| 2099 | { | ||
| 2100 | ✗ | BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h); | |
| 2101 | ✗ | clear_bitmap(pbmp2); | |
| 2102 | |||
| 2103 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 2104 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 2105 | ✗ | draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset); | |
| 2106 | |||
| 2107 | ✗ | destroy_bitmap(pbmp2); | |
| 2108 | } | ||
| 2109 | } | ||
| 2110 | else // no opacity | ||
| 2111 | { | ||
| 2112 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 2113 | ✗ | stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 2114 | } | ||
| 2115 | |||
| 2116 | } | ||
| 2117 | else //no stretch | ||
| 2118 | { | ||
| 2119 | ✗ | if(opacity < 128) | |
| 2120 | { | ||
| 2121 | ✗ | FONT* font = get_zc_font(font_index); | |
| 2122 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font)); | |
| 2123 | ✗ | clear_bitmap(pbmp); | |
| 2124 | |||
| 2125 | ✗ | textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color); | |
| 2126 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 2127 | |||
| 2128 | ✗ | destroy_bitmap(pbmp); | |
| 2129 | } | ||
| 2130 | else // no opacity | ||
| 2131 | { | ||
| 2132 | ✗ | textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color); | |
| 2133 | } | ||
| 2134 | } | ||
| 2135 | } | ||
| 2136 | } | ||
| 2137 | |||
| 2138 | |||
| 2139 | 26828 | void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2140 | { | ||
| 2141 | //sdci[1]=layer | ||
| 2142 | //sdci[2]=x | ||
| 2143 | //sdci[3]=y | ||
| 2144 | //sdci[4]=font | ||
| 2145 | //sdci[5]=color | ||
| 2146 | //sdci[6]=bg color | ||
| 2147 | //sdci[7]=format_option | ||
| 2148 | //sdci[8]=string | ||
| 2149 | //sdci[9]=opacity | ||
| 2150 | |||
| 2151 | 26828 | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 2152 | |||
| 2153 |
1/2✓ Branch 0 taken 26828 times.
✗ Branch 1 not taken.
|
26828 | if(!str) |
| 2154 | { | ||
| 2155 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 2156 | ✗ | return; | |
| 2157 | } | ||
| 2158 | |||
| 2159 | 26828 | int32_t x=sdci[2]/10000; | |
| 2160 | 26828 | int32_t y=sdci[3]/10000; | |
| 2161 | 26828 | FONT* font=get_zc_font(sdci[4]/10000); | |
| 2162 | 26828 | int32_t color=sdci[5]/10000; | |
| 2163 | 26828 | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 2164 | 26828 | int32_t format_type=sdci[7]/10000; | |
| 2165 | 26828 | int32_t opacity=sdci[9]/10000; | |
| 2166 | //sdci[8] not needed :) | ||
| 2167 | |||
| 2168 | //safe check | ||
| 2169 |
1/2✓ Branch 0 taken 26828 times.
✗ Branch 1 not taken.
|
26828 | if(bg_color < -1) bg_color = -1; |
| 2170 | |||
| 2171 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 26828 times.
|
26828 | if(opacity < 128) |
| 2172 | { | ||
| 2173 | ✗ | int32_t width=zc_min(text_length(font, str->c_str()), 512); | |
| 2174 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font)); | |
| 2175 | ✗ | clear_bitmap(pbmp); | |
| 2176 | ✗ | textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color); | |
| 2177 | ✗ | if(format_type == 2) // right-sided text | |
| 2178 | ✗ | x-=width; | |
| 2179 | ✗ | else if(format_type == 1) // centered text | |
| 2180 | ✗ | x-=width/2; | |
| 2181 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 2182 | ✗ | destroy_bitmap(pbmp); | |
| 2183 | } | ||
| 2184 | else // no opacity | ||
| 2185 | { | ||
| 2186 |
2/2✓ Branch 0 taken 7196 times.
✓ Branch 1 taken 19632 times.
|
26828 | if(format_type == 2) // right-sided text |
| 2187 | { | ||
| 2188 | 7196 | textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 2189 | 7196 | } | |
| 2190 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19632 times.
|
19632 | else if(format_type == 1) // centered text |
| 2191 | { | ||
| 2192 | ✗ | textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 2193 | } | ||
| 2194 | else // standard left-sided text | ||
| 2195 | { | ||
| 2196 | 19632 | textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 2197 | } | ||
| 2198 | } | ||
| 2199 | 26828 | } | |
| 2200 | |||
| 2201 | ✗ | void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2202 | { | ||
| 2203 | //sdci[1]=layer | ||
| 2204 | //sdci[2]=x | ||
| 2205 | //sdci[3]=y | ||
| 2206 | //sdci[4]=font | ||
| 2207 | //sdci[5]=color | ||
| 2208 | //sdci[6]=bg color | ||
| 2209 | //sdci[7]=format_option | ||
| 2210 | //sdci[8]=string | ||
| 2211 | //sdci[9]=opacity | ||
| 2212 | //sdci[10]=shadowtype | ||
| 2213 | //sdci[11]=shadow_color | ||
| 2214 | |||
| 2215 | ✗ | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 2216 | |||
| 2217 | ✗ | if(!str) | |
| 2218 | { | ||
| 2219 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 2220 | ✗ | return; | |
| 2221 | } | ||
| 2222 | |||
| 2223 | ✗ | int32_t x=sdci[2]/10000; | |
| 2224 | ✗ | int32_t y=sdci[3]/10000; | |
| 2225 | ✗ | FONT* font=get_zc_font(sdci[4]/10000); | |
| 2226 | ✗ | int32_t color=sdci[5]/10000; | |
| 2227 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 2228 | ✗ | int32_t format_type=sdci[7]/10000; | |
| 2229 | ✗ | int32_t opacity=sdci[9]/10000; | |
| 2230 | ✗ | int32_t textstyle = sdci[10]/10000; | |
| 2231 | ✗ | int32_t shadow_color = sdci[11]/10000; | |
| 2232 | //sdci[8] not needed :) | ||
| 2233 | |||
| 2234 | //safe check | ||
| 2235 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 2236 | |||
| 2237 | ✗ | if(opacity < 128) | |
| 2238 | { | ||
| 2239 | ✗ | int32_t width=zc_min(text_length(font, str->c_str()), 512); | |
| 2240 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font)); | |
| 2241 | ✗ | clear_bitmap(pbmp); | |
| 2242 | ✗ | textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color); | |
| 2243 | ✗ | textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color); | |
| 2244 | ✗ | if(format_type == 2) // right-sided text | |
| 2245 | ✗ | x-=width; | |
| 2246 | ✗ | else if(format_type == 1) // centered text | |
| 2247 | ✗ | x-=width/2; | |
| 2248 | ✗ | draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset); | |
| 2249 | ✗ | destroy_bitmap(pbmp); | |
| 2250 | } | ||
| 2251 | else // no opacity | ||
| 2252 | { | ||
| 2253 | ✗ | textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color); | |
| 2254 | } | ||
| 2255 | } | ||
| 2256 | |||
| 2257 | |||
| 2258 | ✗ | void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2259 | { | ||
| 2260 | //sdci[1]=layer | ||
| 2261 | //sdci[2]=x1 | ||
| 2262 | //sdci[3]=y1 | ||
| 2263 | //sdci[4]=x2 | ||
| 2264 | //sdci[5]=y2 | ||
| 2265 | //sdci[6]=x3 | ||
| 2266 | //sdci[7]=y3 | ||
| 2267 | //sdci[8]=x4 | ||
| 2268 | //sdci[9]=y4 | ||
| 2269 | //sdci[10]=width | ||
| 2270 | //sdci[11]=height | ||
| 2271 | //sdci[12]=cset | ||
| 2272 | //sdci[13]=flip | ||
| 2273 | //sdci[14]=tile/combo | ||
| 2274 | //sdci[15]=polytype | ||
| 2275 | |||
| 2276 | ✗ | int32_t x1 = sdci[2]/10000; | |
| 2277 | ✗ | int32_t y1 = sdci[3]/10000; | |
| 2278 | ✗ | int32_t x2 = sdci[4]/10000; | |
| 2279 | ✗ | int32_t y2 = sdci[5]/10000; | |
| 2280 | ✗ | int32_t x3 = sdci[6]/10000; | |
| 2281 | ✗ | int32_t y3 = sdci[7]/10000; | |
| 2282 | ✗ | int32_t x4 = sdci[8]/10000; | |
| 2283 | ✗ | int32_t y4 = sdci[9]/10000; | |
| 2284 | ✗ | int32_t w = sdci[10]/10000; | |
| 2285 | ✗ | int32_t h = sdci[11]/10000; | |
| 2286 | ✗ | int32_t color = sdci[12]/10000; | |
| 2287 | ✗ | int32_t flip=(sdci[13]/10000)&3; | |
| 2288 | ✗ | int32_t tile = sdci[14]/10000; | |
| 2289 | ✗ | int32_t polytype = sdci[15]/10000; | |
| 2290 | |||
| 2291 | //todo: finish palette shading | ||
| 2292 | /* | ||
| 2293 | POLYTYPE_FLAT | ||
| 2294 | POLYTYPE_GCOL | ||
| 2295 | POLYTYPE_GRGB | ||
| 2296 | POLYTYPE_ATEX | ||
| 2297 | POLYTYPE_PTEX | ||
| 2298 | POLYTYPE_ATEX_MASK | ||
| 2299 | POLYTYPE_PTEX_MASK | ||
| 2300 | POLYTYPE_ATEX_LIT | ||
| 2301 | POLYTYPE_PTEX_LIT | ||
| 2302 | POLYTYPE_ATEX_MASK_LIT | ||
| 2303 | POLYTYPE_PTEX_MASK_LIT | ||
| 2304 | POLYTYPE_ATEX_TRANS | ||
| 2305 | POLYTYPE_PTEX_TRANS | ||
| 2306 | POLYTYPE_ATEX_MASK_TRANS | ||
| 2307 | POLYTYPE_PTEX_MASK_TRANS | ||
| 2308 | */ | ||
| 2309 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 2310 | |||
| 2311 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 2312 | { | ||
| 2313 | ✗ | Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 2314 | ✗ | return; //non power of two error | |
| 2315 | } | ||
| 2316 | |||
| 2317 | ✗ | int32_t tex_width = w*16; | |
| 2318 | ✗ | int32_t tex_height = h*16; | |
| 2319 | |||
| 2320 | BITMAP *tex; | ||
| 2321 | |||
| 2322 | ✗ | bool mustDestroyBmp = false; | |
| 2323 | |||
| 2324 | ✗ | if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519); | |
| 2325 | ✗ | else tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 2326 | |||
| 2327 | ✗ | if(!tex) | |
| 2328 | { | ||
| 2329 | ✗ | mustDestroyBmp = true; | |
| 2330 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 2331 | ✗ | clear_bitmap(tex); | |
| 2332 | } | ||
| 2333 | |||
| 2334 | int32_t col[4]; | ||
| 2335 | /* | ||
| 2336 | if( color < 0 ) | ||
| 2337 | { | ||
| 2338 | col[0]=draw_container.color_buffer[0]; | ||
| 2339 | col[1]=draw_container.color_buffer[1]; | ||
| 2340 | col[2]=draw_container.color_buffer[2]; | ||
| 2341 | col[3]=draw_container.color_buffer[3]; | ||
| 2342 | } | ||
| 2343 | else */ | ||
| 2344 | { | ||
| 2345 | ✗ | col[0]=col[1]=col[2]=col[3]=color; | |
| 2346 | } | ||
| 2347 | |||
| 2348 | ✗ | if(tile > 0 && tile <= 65519) // TILE | |
| 2349 | { | ||
| 2350 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip); | |
| 2351 | } | ||
| 2352 | |||
| 2353 | ✗ | if ( tile < 0 ) // COMBO | |
| 2354 | { | ||
| 2355 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 2356 | ✗ | const int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 2357 | ✗ | flip = flip ^ c.flip; | |
| 2358 | |||
| 2359 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip); | |
| 2360 | } | ||
| 2361 | |||
| 2362 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 2363 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] }; | |
| 2364 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] }; | |
| 2365 | ✗ | V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] }; | |
| 2366 | |||
| 2367 | ✗ | quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4); | |
| 2368 | |||
| 2369 | ✗ | if(mustDestroyBmp) | |
| 2370 | ✗ | destroy_bitmap(tex); | |
| 2371 | |||
| 2372 | } | ||
| 2373 | |||
| 2374 | |||
| 2375 | ✗ | void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2376 | { | ||
| 2377 | //sdci[1]=layer | ||
| 2378 | //sdci[2]=x1 | ||
| 2379 | //sdci[3]=y1 | ||
| 2380 | //sdci[4]=x2 | ||
| 2381 | //sdci[5]=y2 | ||
| 2382 | //sdci[6]=x3 | ||
| 2383 | //sdci[7]=y3 | ||
| 2384 | //sdci[8]=width | ||
| 2385 | //sdci[9]=height | ||
| 2386 | //sdci[10]=cset | ||
| 2387 | //sdci[11]=flip | ||
| 2388 | //sdci[12]=tile/combo | ||
| 2389 | //sdci[13]=polytype | ||
| 2390 | |||
| 2391 | ✗ | int32_t x1 = sdci[2]/10000; | |
| 2392 | ✗ | int32_t y1 = sdci[3]/10000; | |
| 2393 | ✗ | int32_t x2 = sdci[4]/10000; | |
| 2394 | ✗ | int32_t y2 = sdci[5]/10000; | |
| 2395 | ✗ | int32_t x3 = sdci[6]/10000; | |
| 2396 | ✗ | int32_t y3 = sdci[7]/10000; | |
| 2397 | ✗ | int32_t w = sdci[8]/10000; | |
| 2398 | ✗ | int32_t h = sdci[9]/10000; | |
| 2399 | ✗ | int32_t color = sdci[10]/10000; | |
| 2400 | ✗ | int32_t flip=(sdci[11]/10000)&3; | |
| 2401 | ✗ | int32_t tile = sdci[12]/10000; | |
| 2402 | ✗ | int32_t polytype = sdci[13]/10000; | |
| 2403 | |||
| 2404 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 2405 | |||
| 2406 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 2407 | { | ||
| 2408 | ✗ | Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 2409 | ✗ | return; //non power of two error | |
| 2410 | } | ||
| 2411 | |||
| 2412 | ✗ | int32_t tex_width = w*16; | |
| 2413 | ✗ | int32_t tex_height = h*16; | |
| 2414 | |||
| 2415 | ✗ | bool mustDestroyBmp = false; | |
| 2416 | ✗ | BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 2417 | |||
| 2418 | ✗ | if(!tex) | |
| 2419 | { | ||
| 2420 | ✗ | mustDestroyBmp = true; | |
| 2421 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 2422 | ✗ | clear_bitmap(tex); | |
| 2423 | } | ||
| 2424 | |||
| 2425 | int32_t col[3]; | ||
| 2426 | /* | ||
| 2427 | if( color < 0 ) | ||
| 2428 | { | ||
| 2429 | col[0]=draw_container.color_buffer[0]; | ||
| 2430 | col[1]=draw_container.color_buffer[1]; | ||
| 2431 | col[2]=draw_container.color_buffer[2]; | ||
| 2432 | } | ||
| 2433 | else */ | ||
| 2434 | { | ||
| 2435 | ✗ | col[0]=col[1]=col[2]=color; | |
| 2436 | } | ||
| 2437 | |||
| 2438 | ✗ | if(tile > 0) // TILE | |
| 2439 | { | ||
| 2440 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip); | |
| 2441 | } | ||
| 2442 | else // COMBO | ||
| 2443 | { | ||
| 2444 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 2445 | ✗ | const int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 2446 | ✗ | flip = flip ^ c.flip; | |
| 2447 | |||
| 2448 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip); | |
| 2449 | } | ||
| 2450 | |||
| 2451 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 2452 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] }; | |
| 2453 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] }; | |
| 2454 | |||
| 2455 | |||
| 2456 | ✗ | triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3); | |
| 2457 | |||
| 2458 | ✗ | if(mustDestroyBmp) | |
| 2459 | ✗ | destroy_bitmap(tex); | |
| 2460 | } | ||
| 2461 | |||
| 2462 | |||
| 2463 | ✗ | void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2464 | { | ||
| 2465 | //sdci[1]=layer | ||
| 2466 | //sdci[2]=bitmap | ||
| 2467 | //sdci[3]=sourcex | ||
| 2468 | //sdci[4]=sourcey | ||
| 2469 | //sdci[5]=sourcew | ||
| 2470 | //sdci[6]=sourceh | ||
| 2471 | //sdci[7]=destx | ||
| 2472 | //sdci[8]=desty | ||
| 2473 | //sdci[9]=destw | ||
| 2474 | //sdci[10]=desth | ||
| 2475 | //sdci[11]=rotation | ||
| 2476 | //sdci[12]=mask | ||
| 2477 | |||
| 2478 | ✗ | int32_t bitmapIndex = sdci[2]/10000; | |
| 2479 | ✗ | int32_t sx = sdci[3]/10000; | |
| 2480 | ✗ | int32_t sy = sdci[4]/10000; | |
| 2481 | ✗ | int32_t sw = sdci[5]/10000; | |
| 2482 | ✗ | int32_t sh = sdci[6]/10000; | |
| 2483 | ✗ | int32_t dx = sdci[7]/10000; | |
| 2484 | ✗ | int32_t dy = sdci[8]/10000; | |
| 2485 | ✗ | int32_t dw = sdci[9]/10000; | |
| 2486 | ✗ | int32_t dh = sdci[10]/10000; | |
| 2487 | ✗ | float rot = sdci[11]/10000; | |
| 2488 | ✗ | bool masked = (sdci[12] != 0); | |
| 2489 | |||
| 2490 | //bugfix | ||
| 2491 | ✗ | sx = vbound(sx, 0, 512); | |
| 2492 | ✗ | sy = vbound(sy, 0, 512); | |
| 2493 | ✗ | sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well | |
| 2494 | ✗ | sh = vbound(sh, 0, 512 - sy); | |
| 2495 | |||
| 2496 | |||
| 2497 | ✗ | if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight) | |
| 2498 | ✗ | return; | |
| 2499 | |||
| 2500 | ✗ | bool stretched = (sw != dw || sh != dh); | |
| 2501 | |||
| 2502 | ✗ | BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | |
| 2503 | |||
| 2504 | ✗ | if(!sourceBitmap) | |
| 2505 | { | ||
| 2506 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex); | |
| 2507 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 2508 | ✗ | return; | |
| 2509 | } | ||
| 2510 | |||
| 2511 | ✗ | BITMAP* subBmp = 0; | |
| 2512 | |||
| 2513 | ✗ | if(rot != 0) | |
| 2514 | { | ||
| 2515 | ✗ | subBmp = script_drawing_commands.AquireSubBitmap(dw, dh); | |
| 2516 | |||
| 2517 | ✗ | if(!subBmp) | |
| 2518 | { | ||
| 2519 | ✗ | Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation"); | |
| 2520 | ✗ | return; | |
| 2521 | } | ||
| 2522 | } | ||
| 2523 | |||
| 2524 | |||
| 2525 | ✗ | dx = dx + xoffset; | |
| 2526 | ✗ | dy = dy + yoffset; | |
| 2527 | |||
| 2528 | ✗ | if(stretched) | |
| 2529 | { | ||
| 2530 | ✗ | if(masked) | |
| 2531 | { | ||
| 2532 | ✗ | if(rot != 0) | |
| 2533 | { | ||
| 2534 | //if ( rot == 4096 ) { //translucent | ||
| 2535 | // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 2536 | // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 2537 | // draw_trans_sprite(bmp, subBmp, dx, dy); | ||
| 2538 | // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0); | ||
| 2539 | |||
| 2540 | |||
| 2541 | // } | ||
| 2542 | //else { | ||
| 2543 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2544 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2545 | //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 2546 | // | ||
| 2547 | |||
| 2548 | // } | ||
| 2549 | } | ||
| 2550 | else | ||
| 2551 | ✗ | masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 2552 | } | ||
| 2553 | else | ||
| 2554 | { | ||
| 2555 | ✗ | if(rot != 0) | |
| 2556 | { | ||
| 2557 | //if ( rot == 4096 ) { //translucent | ||
| 2558 | // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 2559 | // draw_trans_sprite(bmp, subBmp, dx, dy); | ||
| 2560 | // } | ||
| 2561 | //else { | ||
| 2562 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2563 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2564 | // } | ||
| 2565 | } | ||
| 2566 | else | ||
| 2567 | ✗ | stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 2568 | } | ||
| 2569 | } | ||
| 2570 | else | ||
| 2571 | { | ||
| 2572 | ✗ | if(masked) | |
| 2573 | { | ||
| 2574 | ✗ | if(rot != 0) | |
| 2575 | { | ||
| 2576 | //if ( rot == 4096 ) {//translucent | ||
| 2577 | // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 2578 | //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 2579 | |||
| 2580 | //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 2581 | //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 2582 | // draw_trans_sprite(bmp, subBmp, dx, dy); | ||
| 2583 | // } | ||
| 2584 | //else { | ||
| 2585 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 2586 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2587 | // } | ||
| 2588 | } | ||
| 2589 | else | ||
| 2590 | ✗ | masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh); | |
| 2591 | } | ||
| 2592 | else | ||
| 2593 | { | ||
| 2594 | ✗ | if(rot != 0) | |
| 2595 | { | ||
| 2596 | //if ( rot == 4096 ) { //translucent | ||
| 2597 | // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 2598 | // draw_trans_sprite(bmp, subBmp, dx, dy); | ||
| 2599 | // } | ||
| 2600 | //else { | ||
| 2601 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 2602 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2603 | // } | ||
| 2604 | } | ||
| 2605 | else | ||
| 2606 | ✗ | blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh); | |
| 2607 | } | ||
| 2608 | } | ||
| 2609 | |||
| 2610 | //cleanup | ||
| 2611 | ✗ | if(subBmp) | |
| 2612 | { | ||
| 2613 | ✗ | script_drawing_commands.ReleaseSubBitmap(subBmp); | |
| 2614 | } | ||
| 2615 | } | ||
| 2616 | |||
| 2617 | |||
| 2618 | //Draw]() | ||
| 2619 | ✗ | void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 2620 | { | ||
| 2621 | /* | ||
| 2622 | //sdci[1]=layer | ||
| 2623 | //sdci[2]=bitmap | ||
| 2624 | //sdci[3]=sourcex | ||
| 2625 | //sdci[4]=sourcey | ||
| 2626 | //sdci[5]=sourcew | ||
| 2627 | //sdci[6]=sourceh | ||
| 2628 | //sdci[7]=destx | ||
| 2629 | //sdci[8]=desty | ||
| 2630 | //sdci[9]=destw | ||
| 2631 | //sdci[10]=desth | ||
| 2632 | //sdci[11]=rotation/angle | ||
| 2633 | //scdi[12] = pivot cx | ||
| 2634 | //sdci[13] = pivot cy | ||
| 2635 | //scdi[14] = effect flags | ||
| 2636 | |||
| 2637 | |||
| 2638 | const int32_t BITDX_NORMAL = 0; | ||
| 2639 | const int32_t BITDX_TRANS = 1; //Translucent | ||
| 2640 | const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center. | ||
| 2641 | const int32_t BITDX_HFLIP = 4; //Horizontal Flip | ||
| 2642 | const int32_t BITDX_VFLIP = 8; //Vertical Flip. | ||
| 2643 | //Note: Some modes cannot be combined. if a combination is not supported, an error | ||
| 2644 | // detailing this will be shown in allegro.log. | ||
| 2645 | |||
| 2646 | //scdi[15] = litcolour | ||
| 2647 | //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | ||
| 2648 | /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 2649 | |||
| 2650 | //sdci[16]=mask | ||
| 2651 | |||
| 2652 | */ | ||
| 2653 | |||
| 2654 | ✗ | int32_t bitmapIndex = sdci[2]/10000; | |
| 2655 | ✗ | int32_t sx = sdci[3]/10000; | |
| 2656 | ✗ | int32_t sy = sdci[4]/10000; | |
| 2657 | ✗ | int32_t sw = sdci[5]/10000; | |
| 2658 | ✗ | int32_t sh = sdci[6]/10000; | |
| 2659 | ✗ | int32_t dx = sdci[7]/10000; | |
| 2660 | ✗ | int32_t dy = sdci[8]/10000; | |
| 2661 | ✗ | int32_t dw = sdci[9]/10000; | |
| 2662 | ✗ | int32_t dh = sdci[10]/10000; | |
| 2663 | ✗ | float rot = sdci[11]/10000; | |
| 2664 | ✗ | int32_t cx = sdci[12]/10000; | |
| 2665 | ✗ | int32_t cy = sdci[13]/10000; | |
| 2666 | ✗ | int32_t mode = sdci[14]/10000; | |
| 2667 | ✗ | int32_t litcolour = sdci[15]/10000; | |
| 2668 | ✗ | bool masked = (sdci[16] != 0); | |
| 2669 | |||
| 2670 | |||
| 2671 | |||
| 2672 | //bugfix | ||
| 2673 | ✗ | sx = vbound(sx, 0, 512); | |
| 2674 | ✗ | sy = vbound(sy, 0, 512); | |
| 2675 | ✗ | sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well | |
| 2676 | ✗ | sh = vbound(sh, 0, 512 - sy); | |
| 2677 | |||
| 2678 | |||
| 2679 | ✗ | if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight) | |
| 2680 | ✗ | return; | |
| 2681 | |||
| 2682 | ✗ | bool stretched = (sw != dw || sh != dh); | |
| 2683 | |||
| 2684 | ✗ | BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | |
| 2685 | |||
| 2686 | ✗ | if(!sourceBitmap) | |
| 2687 | { | ||
| 2688 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex); | |
| 2689 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 2690 | ✗ | return; | |
| 2691 | } | ||
| 2692 | |||
| 2693 | ✗ | BITMAP* subBmp = 0; | |
| 2694 | |||
| 2695 | /* | ||
| 2696 | if ( bitmapIndex == -1 ) { | ||
| 2697 | blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh); | ||
| 2698 | } | ||
| 2699 | */ | ||
| 2700 | |||
| 2701 | ✗ | if(rot != 0 || mode != 0) | |
| 2702 | { | ||
| 2703 | ✗ | subBmp = script_drawing_commands.AquireSubBitmap(dw, dh); | |
| 2704 | |||
| 2705 | ✗ | if(!subBmp) | |
| 2706 | { | ||
| 2707 | ✗ | Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation"); | |
| 2708 | ✗ | return; | |
| 2709 | } | ||
| 2710 | } | ||
| 2711 | |||
| 2712 | |||
| 2713 | ✗ | dx = dx + xoffset; | |
| 2714 | ✗ | dy = dy + yoffset; | |
| 2715 | |||
| 2716 | ✗ | if(stretched) | |
| 2717 | { | ||
| 2718 | ✗ | if(masked) //stretched and masked | |
| 2719 | { | ||
| 2720 | ✗ | if ( rot == 0 ) //if not rotated | |
| 2721 | { | ||
| 2722 | ✗ | switch(mode) | |
| 2723 | { | ||
| 2724 | case 1: | ||
| 2725 | //transparent | ||
| 2726 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2727 | ✗ | draw_trans_sprite(bmp, subBmp, dx, dy); | |
| 2728 | ✗ | break; | |
| 2729 | |||
| 2730 | |||
| 2731 | case 2: | ||
| 2732 | //pivot? | ||
| 2733 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2734 | ✗ | pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 2735 | //Pivoting requires two more args | ||
| 2736 | ✗ | break; | |
| 2737 | |||
| 2738 | case 3: | ||
| 2739 | //pivot + trans | ||
| 2740 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2741 | ✗ | pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 2742 | ✗ | break; | |
| 2743 | |||
| 2744 | case 4: | ||
| 2745 | //flip v | ||
| 2746 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2747 | ✗ | draw_sprite_v_flip(bmp, subBmp, dx, dy); | |
| 2748 | ✗ | break; | |
| 2749 | |||
| 2750 | case 5: | ||
| 2751 | //trans + v flip | ||
| 2752 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2753 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 2754 | ✗ | break; | |
| 2755 | |||
| 2756 | case 6: | ||
| 2757 | //pivot + v flip | ||
| 2758 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2759 | ✗ | pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 2760 | ✗ | break; | |
| 2761 | |||
| 2762 | case 8: | ||
| 2763 | //vlip h | ||
| 2764 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2765 | ✗ | draw_sprite_h_flip(bmp, subBmp, dx, dy); | |
| 2766 | ✗ | break; | |
| 2767 | |||
| 2768 | case 9: | ||
| 2769 | //trans + h flip | ||
| 2770 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2771 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 2772 | ✗ | break; | |
| 2773 | |||
| 2774 | case 10: | ||
| 2775 | //flip H and pivot | ||
| 2776 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 2777 | //return error cannot pivot and h flip | ||
| 2778 | ✗ | break; | |
| 2779 | |||
| 2780 | case 12: | ||
| 2781 | //vh flip | ||
| 2782 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2783 | ✗ | draw_sprite_vh_flip(bmp, subBmp, dx, dy); | |
| 2784 | ✗ | break; | |
| 2785 | |||
| 2786 | case 13: | ||
| 2787 | //trans + vh flip | ||
| 2788 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2789 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 2790 | ✗ | break; | |
| 2791 | |||
| 2792 | case 14: | ||
| 2793 | //pivot and vh flip | ||
| 2794 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 2795 | //return error cannot both pivot and vh flip | ||
| 2796 | ✗ | break; | |
| 2797 | |||
| 2798 | case 16: | ||
| 2799 | //lit | ||
| 2800 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2801 | ✗ | draw_lit_sprite(bmp, subBmp, dx, dy, litcolour); | |
| 2802 | ✗ | break; | |
| 2803 | |||
| 2804 | case 18: | ||
| 2805 | //pivot, lit | ||
| 2806 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2807 | ✗ | pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 2808 | ✗ | break; | |
| 2809 | |||
| 2810 | case 20: | ||
| 2811 | //lit + v flip | ||
| 2812 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2813 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 2814 | ✗ | break; | |
| 2815 | |||
| 2816 | case 22: | ||
| 2817 | //Pivot, vflip, lit | ||
| 2818 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2819 | ✗ | pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 2820 | ✗ | break; | |
| 2821 | |||
| 2822 | case 24: | ||
| 2823 | //lit + h flip | ||
| 2824 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2825 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 2826 | ✗ | break; | |
| 2827 | |||
| 2828 | case 26: | ||
| 2829 | //pivot + lit + hflip | ||
| 2830 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 2831 | //return error cannot pivot, lit, and flip | ||
| 2832 | ✗ | break; | |
| 2833 | |||
| 2834 | case 28: | ||
| 2835 | //lit + vh flip | ||
| 2836 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2837 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 2838 | ✗ | break; | |
| 2839 | |||
| 2840 | case 32: //gouraud | ||
| 2841 | //Probably not wort supporting. | ||
| 2842 | //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 2843 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 2844 | ✗ | break; | |
| 2845 | |||
| 2846 | case 0: | ||
| 2847 | //no effect | ||
| 2848 | ✗ | masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 2849 | ✗ | break; | |
| 2850 | |||
| 2851 | |||
| 2852 | default: | ||
| 2853 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 2854 | |||
| 2855 | |||
| 2856 | } | ||
| 2857 | } //end if not rotated | ||
| 2858 | |||
| 2859 | ✗ | if ( rot != 0 ) //if rotated | |
| 2860 | { | ||
| 2861 | ✗ | switch(mode) | |
| 2862 | { | ||
| 2863 | case 1: | ||
| 2864 | //transparent | ||
| 2865 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2866 | ✗ | rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2867 | |||
| 2868 | ✗ | break; | |
| 2869 | |||
| 2870 | case 2: | ||
| 2871 | //pivot? | ||
| 2872 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 2873 | //return an error, cannot both rotate and pivot | ||
| 2874 | ✗ | break; | |
| 2875 | |||
| 2876 | case 3: | ||
| 2877 | //pivot + trans | ||
| 2878 | //return an error, cannot both rotate and pivot | ||
| 2879 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 2880 | ✗ | break; | |
| 2881 | |||
| 2882 | case 4: | ||
| 2883 | //flip v | ||
| 2884 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2885 | ✗ | rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2886 | ✗ | break; | |
| 2887 | |||
| 2888 | case 5: | ||
| 2889 | //trans + v flip | ||
| 2890 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2891 | ✗ | rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2892 | ✗ | break; | |
| 2893 | |||
| 2894 | case 6: | ||
| 2895 | //pivot + v flip | ||
| 2896 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 2897 | //return an error, cannot both rotate and pivot | ||
| 2898 | ✗ | break; | |
| 2899 | |||
| 2900 | case 8: | ||
| 2901 | //flip h | ||
| 2902 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 2903 | //return an error, cannot both rotate and flip H | ||
| 2904 | ✗ | break; | |
| 2905 | |||
| 2906 | case 9: | ||
| 2907 | //trans + h flip | ||
| 2908 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 2909 | //return an error, cannot rotate and flip a trans sprite | ||
| 2910 | ✗ | break; | |
| 2911 | |||
| 2912 | case 10: | ||
| 2913 | //flip H and pivot | ||
| 2914 | //return error cannot pivot and h flip | ||
| 2915 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 2916 | ✗ | break; | |
| 2917 | |||
| 2918 | case 12: | ||
| 2919 | //vh flip | ||
| 2920 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 2921 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 2922 | ✗ | break; | |
| 2923 | |||
| 2924 | case 13: | ||
| 2925 | //trans + vh flip | ||
| 2926 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 2927 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 2928 | ✗ | break; | |
| 2929 | |||
| 2930 | case 14: | ||
| 2931 | //pivot and vh flip | ||
| 2932 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 2933 | //return error cannot both pivot and vh flip | ||
| 2934 | ✗ | break; | |
| 2935 | |||
| 2936 | case 16: | ||
| 2937 | //lit | ||
| 2938 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2939 | ✗ | rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 2940 | ✗ | break; | |
| 2941 | |||
| 2942 | case 18: | ||
| 2943 | //pivot, lit | ||
| 2944 | //return an error, cannot both rotate and pivot | ||
| 2945 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 2946 | ✗ | break; | |
| 2947 | |||
| 2948 | case 20: | ||
| 2949 | //lit + vflip | ||
| 2950 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2951 | ✗ | rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 2952 | ✗ | break; | |
| 2953 | |||
| 2954 | case 22: | ||
| 2955 | //Pivot, vflip, lit | ||
| 2956 | //return an error, cannot both rotate and pivot | ||
| 2957 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 2958 | ✗ | break; | |
| 2959 | |||
| 2960 | case 24: | ||
| 2961 | //lit + h flip | ||
| 2962 | //return an error, cannot both rotate and H flip | ||
| 2963 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 2964 | ✗ | break; | |
| 2965 | |||
| 2966 | case 26: | ||
| 2967 | //pivot + lit + hflip | ||
| 2968 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 2969 | //return error cannot pivot, lit, and flip | ||
| 2970 | ✗ | break; | |
| 2971 | |||
| 2972 | case 28: | ||
| 2973 | //lit + vh flip | ||
| 2974 | //return an error, cannot both rotate and VH flip | ||
| 2975 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 2976 | ✗ | break; | |
| 2977 | |||
| 2978 | case 32: //gouraud | ||
| 2979 | //Probably not wort supporting. | ||
| 2980 | //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 2981 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 2982 | ✗ | break; | |
| 2983 | |||
| 2984 | case 0: | ||
| 2985 | //no effect. | ||
| 2986 | ✗ | masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 2987 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 2988 | ✗ | break; | |
| 2989 | |||
| 2990 | default: | ||
| 2991 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 2992 | |||
| 2993 | } | ||
| 2994 | } | ||
| 2995 | } //end if stretched and masked | ||
| 2996 | |||
| 2997 | else //stretched, not masked | ||
| 2998 | { | ||
| 2999 | ✗ | if ( rot == 0 ) //if not rotated | |
| 3000 | { | ||
| 3001 | ✗ | switch(mode) { | |
| 3002 | case 1: | ||
| 3003 | //transparent | ||
| 3004 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3005 | ✗ | draw_trans_sprite(bmp, subBmp, dx, dy); | |
| 3006 | ✗ | break; | |
| 3007 | |||
| 3008 | |||
| 3009 | case 2: | ||
| 3010 | //pivot? | ||
| 3011 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3012 | ✗ | pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3013 | //Pivoting requires two more args | ||
| 3014 | ✗ | break; | |
| 3015 | |||
| 3016 | case 3: | ||
| 3017 | //pivot + trans | ||
| 3018 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3019 | ✗ | pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot)); | |
| 3020 | ✗ | break; | |
| 3021 | |||
| 3022 | case 4: | ||
| 3023 | //flip v | ||
| 3024 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3025 | ✗ | draw_sprite_v_flip(bmp, subBmp, dx, dy); | |
| 3026 | ✗ | break; | |
| 3027 | |||
| 3028 | case 5: | ||
| 3029 | //trans + v flip | ||
| 3030 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3031 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 3032 | ✗ | break; | |
| 3033 | |||
| 3034 | case 6: | ||
| 3035 | //pivot + v flip | ||
| 3036 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3037 | ✗ | pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3038 | ✗ | break; | |
| 3039 | |||
| 3040 | case 8: | ||
| 3041 | //vlip h | ||
| 3042 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3043 | ✗ | draw_sprite_h_flip(bmp, subBmp, dx, dy); | |
| 3044 | ✗ | break; | |
| 3045 | |||
| 3046 | case 9: | ||
| 3047 | //trans + h flip | ||
| 3048 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3049 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 3050 | ✗ | break; | |
| 3051 | |||
| 3052 | case 10: | ||
| 3053 | //flip H and pivot | ||
| 3054 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3055 | //return error cannot pivot and h flip | ||
| 3056 | ✗ | break; | |
| 3057 | |||
| 3058 | case 12: | ||
| 3059 | //vh flip | ||
| 3060 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3061 | ✗ | draw_sprite_vh_flip(bmp, subBmp, dx, dy); | |
| 3062 | ✗ | break; | |
| 3063 | |||
| 3064 | case 13: | ||
| 3065 | //trans + vh flip | ||
| 3066 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3067 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 3068 | ✗ | break; | |
| 3069 | |||
| 3070 | case 14: | ||
| 3071 | //pivot and vh flip | ||
| 3072 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3073 | //return error cannot both pivot and vh flip | ||
| 3074 | ✗ | break; | |
| 3075 | |||
| 3076 | case 16: | ||
| 3077 | //lit | ||
| 3078 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3079 | ✗ | draw_lit_sprite(bmp, subBmp, dx, dy, litcolour); | |
| 3080 | ✗ | break; | |
| 3081 | |||
| 3082 | case 18: | ||
| 3083 | //pivot, lit | ||
| 3084 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3085 | ✗ | pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3086 | ✗ | break; | |
| 3087 | |||
| 3088 | case 20: | ||
| 3089 | //lit + v flip | ||
| 3090 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3091 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 3092 | ✗ | break; | |
| 3093 | |||
| 3094 | case 22: | ||
| 3095 | //Pivot, vflip, lit | ||
| 3096 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3097 | ✗ | pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3098 | ✗ | break; | |
| 3099 | |||
| 3100 | case 24: | ||
| 3101 | //lit + h flip | ||
| 3102 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3103 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 3104 | ✗ | break; | |
| 3105 | |||
| 3106 | case 26: | ||
| 3107 | //pivot + lit + hflip | ||
| 3108 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 3109 | //return error cannot pivot, lit, and flip | ||
| 3110 | ✗ | break; | |
| 3111 | |||
| 3112 | case 28: | ||
| 3113 | //lit + vh flip | ||
| 3114 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3115 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 3116 | ✗ | break; | |
| 3117 | |||
| 3118 | case 32: //gouraud | ||
| 3119 | //Probably not wort supporting. | ||
| 3120 | //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 3121 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3122 | ✗ | break; | |
| 3123 | |||
| 3124 | case 0: | ||
| 3125 | //no effect | ||
| 3126 | ✗ | stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 3127 | ✗ | break; | |
| 3128 | |||
| 3129 | |||
| 3130 | default: | ||
| 3131 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3132 | |||
| 3133 | |||
| 3134 | } | ||
| 3135 | } //end if not rotated | ||
| 3136 | |||
| 3137 | ✗ | if ( rot != 0 ) //if rotated | |
| 3138 | { | ||
| 3139 | ✗ | switch(mode) | |
| 3140 | { | ||
| 3141 | case 1: | ||
| 3142 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 3143 | ✗ | rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3144 | |||
| 3145 | ✗ | break; | |
| 3146 | |||
| 3147 | case 2: | ||
| 3148 | //pivot? | ||
| 3149 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3150 | //return an error, cannot both rotate and pivot | ||
| 3151 | ✗ | break; | |
| 3152 | |||
| 3153 | case 3: | ||
| 3154 | //pivot + trans | ||
| 3155 | //return an error, cannot both rotate and pivot | ||
| 3156 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3157 | ✗ | break; | |
| 3158 | |||
| 3159 | case 4: | ||
| 3160 | //flip v | ||
| 3161 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3162 | ✗ | rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3163 | ✗ | break; | |
| 3164 | |||
| 3165 | case 5: | ||
| 3166 | //trans + v flip | ||
| 3167 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3168 | ✗ | rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3169 | ✗ | break; | |
| 3170 | |||
| 3171 | case 6: | ||
| 3172 | //pivot + v flip | ||
| 3173 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3174 | //return an error, cannot both rotate and pivot | ||
| 3175 | ✗ | break; | |
| 3176 | |||
| 3177 | case 8: | ||
| 3178 | //flip h | ||
| 3179 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 3180 | //return an error, cannot both rotate and flip H | ||
| 3181 | ✗ | break; | |
| 3182 | |||
| 3183 | case 9: | ||
| 3184 | //trans + h flip | ||
| 3185 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 3186 | //return an error, cannot rotate and flip a trans sprite | ||
| 3187 | ✗ | break; | |
| 3188 | |||
| 3189 | case 10: | ||
| 3190 | //flip H and pivot | ||
| 3191 | //return error cannot pivot and h flip | ||
| 3192 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3193 | ✗ | break; | |
| 3194 | |||
| 3195 | case 12: | ||
| 3196 | //vh flip | ||
| 3197 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3198 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3199 | ✗ | break; | |
| 3200 | |||
| 3201 | case 13: | ||
| 3202 | //trans + vh flip | ||
| 3203 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3204 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3205 | ✗ | break; | |
| 3206 | |||
| 3207 | case 14: | ||
| 3208 | //pivot and vh flip | ||
| 3209 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3210 | //return error cannot both pivot and vh flip | ||
| 3211 | ✗ | break; | |
| 3212 | |||
| 3213 | case 16: | ||
| 3214 | //lit | ||
| 3215 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 3216 | ✗ | rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3217 | ✗ | break; | |
| 3218 | |||
| 3219 | case 18: | ||
| 3220 | //pivot, lit | ||
| 3221 | //return an error, cannot both rotate and pivot | ||
| 3222 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3223 | ✗ | break; | |
| 3224 | |||
| 3225 | case 20: | ||
| 3226 | //lit + vflip | ||
| 3227 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 3228 | ✗ | rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3229 | ✗ | break; | |
| 3230 | |||
| 3231 | case 22: | ||
| 3232 | //Pivot, vflip, lit | ||
| 3233 | //return an error, cannot both rotate and pivot | ||
| 3234 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3235 | ✗ | break; | |
| 3236 | |||
| 3237 | case 24: | ||
| 3238 | //lit + h flip | ||
| 3239 | //return an error, cannot both rotate and H flip | ||
| 3240 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 3241 | ✗ | break; | |
| 3242 | |||
| 3243 | case 26: | ||
| 3244 | //pivot + lit + hflip | ||
| 3245 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 3246 | //return error cannot pivot, lit, and flip | ||
| 3247 | ✗ | break; | |
| 3248 | |||
| 3249 | case 28: | ||
| 3250 | //lit + vh flip | ||
| 3251 | //return an error, cannot both rotate and VH flip | ||
| 3252 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3253 | ✗ | break; | |
| 3254 | |||
| 3255 | case 32: //gouraud | ||
| 3256 | //Probably not wort supporting. | ||
| 3257 | //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 3258 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3259 | ✗ | break; | |
| 3260 | |||
| 3261 | case 0: | ||
| 3262 | //no effect. | ||
| 3263 | ✗ | stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 3264 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3265 | ✗ | break; | |
| 3266 | |||
| 3267 | default: | ||
| 3268 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3269 | |||
| 3270 | } | ||
| 3271 | } | ||
| 3272 | |||
| 3273 | } //end if stretched, but not masked | ||
| 3274 | } | ||
| 3275 | else //not stretched | ||
| 3276 | { | ||
| 3277 | |||
| 3278 | ✗ | if(masked) //if masked, but not stretched | |
| 3279 | { | ||
| 3280 | |||
| 3281 | ✗ | if ( rot == 0 ) //if not rotated | |
| 3282 | { | ||
| 3283 | ✗ | switch(mode) | |
| 3284 | { | ||
| 3285 | case 1: | ||
| 3286 | //transparent | ||
| 3287 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3288 | ✗ | draw_trans_sprite(bmp, subBmp, dx, dy); | |
| 3289 | ✗ | break; | |
| 3290 | |||
| 3291 | |||
| 3292 | case 2: | ||
| 3293 | //pivot? | ||
| 3294 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3295 | ✗ | pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3296 | //Pivoting requires two more args | ||
| 3297 | ✗ | break; | |
| 3298 | |||
| 3299 | case 3: | ||
| 3300 | //pivot + trans | ||
| 3301 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3302 | ✗ | pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3303 | ✗ | break; | |
| 3304 | |||
| 3305 | case 4: | ||
| 3306 | //flip v | ||
| 3307 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3308 | ✗ | draw_sprite_v_flip(bmp, subBmp, dx, dy); | |
| 3309 | ✗ | break; | |
| 3310 | |||
| 3311 | case 5: | ||
| 3312 | //trans + v flip | ||
| 3313 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3314 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 3315 | ✗ | break; | |
| 3316 | |||
| 3317 | case 6: | ||
| 3318 | //pivot + v flip | ||
| 3319 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3320 | ✗ | pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3321 | ✗ | break; | |
| 3322 | |||
| 3323 | case 8: | ||
| 3324 | //vlip h | ||
| 3325 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3326 | ✗ | draw_sprite_h_flip(bmp, subBmp, dx, dy); | |
| 3327 | ✗ | break; | |
| 3328 | |||
| 3329 | case 9: | ||
| 3330 | //trans + h flip | ||
| 3331 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3332 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 3333 | ✗ | break; | |
| 3334 | |||
| 3335 | case 10: | ||
| 3336 | //flip H and pivot | ||
| 3337 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3338 | //return error cannot pivot and h flip | ||
| 3339 | ✗ | break; | |
| 3340 | |||
| 3341 | case 12: | ||
| 3342 | //vh flip | ||
| 3343 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3344 | ✗ | draw_sprite_vh_flip(bmp, subBmp, dx, dy); | |
| 3345 | ✗ | break; | |
| 3346 | |||
| 3347 | case 13: | ||
| 3348 | //trans + vh flip | ||
| 3349 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3350 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 3351 | ✗ | break; | |
| 3352 | |||
| 3353 | case 14: | ||
| 3354 | //pivot and vh flip | ||
| 3355 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3356 | //return error cannot both pivot and vh flip | ||
| 3357 | ✗ | break; | |
| 3358 | |||
| 3359 | case 16: | ||
| 3360 | //lit | ||
| 3361 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3362 | ✗ | draw_lit_sprite(bmp, subBmp, dx, dy, litcolour); | |
| 3363 | ✗ | break; | |
| 3364 | |||
| 3365 | case 18: | ||
| 3366 | //pivot, lit | ||
| 3367 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3368 | ✗ | pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3369 | ✗ | break; | |
| 3370 | |||
| 3371 | case 20: | ||
| 3372 | //lit + v flip | ||
| 3373 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3374 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 3375 | ✗ | break; | |
| 3376 | |||
| 3377 | case 22: | ||
| 3378 | //Pivot, vflip, lit | ||
| 3379 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3380 | ✗ | pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3381 | ✗ | break; | |
| 3382 | |||
| 3383 | case 24: | ||
| 3384 | //lit + h flip | ||
| 3385 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3386 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 3387 | ✗ | break; | |
| 3388 | |||
| 3389 | case 26: | ||
| 3390 | //pivot + lit + hflip | ||
| 3391 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 3392 | //return error cannot pivot, lit, and flip | ||
| 3393 | ✗ | break; | |
| 3394 | |||
| 3395 | case 28: | ||
| 3396 | //lit + vh flip | ||
| 3397 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3398 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 3399 | ✗ | break; | |
| 3400 | |||
| 3401 | case 32: //gouraud | ||
| 3402 | //Probably not wort supporting. | ||
| 3403 | //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 3404 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3405 | ✗ | break; | |
| 3406 | |||
| 3407 | case 0: | ||
| 3408 | //no effect | ||
| 3409 | ✗ | masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh); | |
| 3410 | ✗ | break; | |
| 3411 | |||
| 3412 | |||
| 3413 | default: | ||
| 3414 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3415 | |||
| 3416 | |||
| 3417 | } | ||
| 3418 | } //end if not rotated | ||
| 3419 | |||
| 3420 | ✗ | if ( rot != 0 ) //if rotated | |
| 3421 | { | ||
| 3422 | ✗ | switch(mode) | |
| 3423 | { | ||
| 3424 | case 1: | ||
| 3425 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent | |
| 3426 | ✗ | rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3427 | |||
| 3428 | ✗ | break; | |
| 3429 | |||
| 3430 | case 2: | ||
| 3431 | //pivot? | ||
| 3432 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3433 | //return an error, cannot both rotate and pivot | ||
| 3434 | ✗ | break; | |
| 3435 | |||
| 3436 | case 3: | ||
| 3437 | //pivot + trans | ||
| 3438 | //return an error, cannot both rotate and pivot | ||
| 3439 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3440 | ✗ | break; | |
| 3441 | |||
| 3442 | case 4: | ||
| 3443 | //flip v | ||
| 3444 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3445 | ✗ | rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3446 | ✗ | break; | |
| 3447 | |||
| 3448 | case 5: | ||
| 3449 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip | |
| 3450 | ✗ | rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3451 | ✗ | break; | |
| 3452 | |||
| 3453 | case 6: | ||
| 3454 | //pivot + v flip | ||
| 3455 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3456 | //return an error, cannot both rotate and pivot | ||
| 3457 | ✗ | break; | |
| 3458 | |||
| 3459 | case 8: | ||
| 3460 | //flip h | ||
| 3461 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 3462 | //return an error, cannot both rotate and flip H | ||
| 3463 | ✗ | break; | |
| 3464 | |||
| 3465 | case 9: | ||
| 3466 | //trans + h flip | ||
| 3467 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 3468 | //return an error, cannot rotate and flip a trans sprite | ||
| 3469 | ✗ | break; | |
| 3470 | |||
| 3471 | case 10: | ||
| 3472 | //flip H and pivot | ||
| 3473 | //return error cannot pivot and h flip | ||
| 3474 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3475 | ✗ | break; | |
| 3476 | |||
| 3477 | case 12: | ||
| 3478 | //vh flip | ||
| 3479 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3480 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3481 | ✗ | break; | |
| 3482 | |||
| 3483 | case 13: | ||
| 3484 | //trans + vh flip | ||
| 3485 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3486 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3487 | ✗ | break; | |
| 3488 | |||
| 3489 | case 14: | ||
| 3490 | //pivot and vh flip | ||
| 3491 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3492 | //return error cannot both pivot and vh flip | ||
| 3493 | ✗ | break; | |
| 3494 | |||
| 3495 | case 16: | ||
| 3496 | //lit | ||
| 3497 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3498 | ✗ | rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3499 | ✗ | break; | |
| 3500 | |||
| 3501 | case 18: | ||
| 3502 | //pivot, lit | ||
| 3503 | //return an error, cannot both rotate and pivot | ||
| 3504 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3505 | ✗ | break; | |
| 3506 | |||
| 3507 | case 20: | ||
| 3508 | //lit + vflip | ||
| 3509 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3510 | ✗ | rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3511 | ✗ | break; | |
| 3512 | |||
| 3513 | case 22: | ||
| 3514 | //Pivot, vflip, lit | ||
| 3515 | //return an error, cannot both rotate and pivot | ||
| 3516 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3517 | ✗ | break; | |
| 3518 | |||
| 3519 | case 24: | ||
| 3520 | //lit + h flip | ||
| 3521 | //return an error, cannot both rotate and H flip | ||
| 3522 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 3523 | ✗ | break; | |
| 3524 | |||
| 3525 | case 26: | ||
| 3526 | //pivot + lit + hflip | ||
| 3527 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 3528 | //return error cannot pivot, lit, and flip | ||
| 3529 | ✗ | break; | |
| 3530 | |||
| 3531 | case 28: | ||
| 3532 | //lit + vh flip | ||
| 3533 | //return an error, cannot both rotate and VH flip | ||
| 3534 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3535 | ✗ | break; | |
| 3536 | |||
| 3537 | case 32: //gouraud | ||
| 3538 | //Probably not wort supporting. | ||
| 3539 | //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 3540 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3541 | ✗ | break; | |
| 3542 | |||
| 3543 | case 0: | ||
| 3544 | //no effect. | ||
| 3545 | ✗ | masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3546 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3547 | ✗ | break; | |
| 3548 | |||
| 3549 | default: | ||
| 3550 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3551 | |||
| 3552 | } | ||
| 3553 | } //end rtated, masked | ||
| 3554 | } //end if masked | ||
| 3555 | |||
| 3556 | else //not masked, and not stretched; just blit | ||
| 3557 | { | ||
| 3558 | |||
| 3559 | ✗ | if ( rot == 0 ) //if not rotated | |
| 3560 | { | ||
| 3561 | ✗ | switch(mode) | |
| 3562 | { | ||
| 3563 | case 1: | ||
| 3564 | //transparent | ||
| 3565 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3566 | ✗ | draw_trans_sprite(bmp, subBmp, dx, dy); | |
| 3567 | ✗ | break; | |
| 3568 | |||
| 3569 | |||
| 3570 | case 2: | ||
| 3571 | //pivot? | ||
| 3572 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3573 | ✗ | pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3574 | //Pivoting requires two more args | ||
| 3575 | ✗ | break; | |
| 3576 | |||
| 3577 | case 3: | ||
| 3578 | //pivot + trans | ||
| 3579 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3580 | ✗ | pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3581 | ✗ | break; | |
| 3582 | |||
| 3583 | case 4: | ||
| 3584 | //flip v | ||
| 3585 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3586 | ✗ | draw_sprite_v_flip(bmp, subBmp, dx, dy); | |
| 3587 | ✗ | break; | |
| 3588 | |||
| 3589 | case 5: | ||
| 3590 | //trans + v flip | ||
| 3591 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3592 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 3593 | ✗ | break; | |
| 3594 | |||
| 3595 | case 6: | ||
| 3596 | //pivot + v flip | ||
| 3597 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3598 | ✗ | pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 3599 | ✗ | break; | |
| 3600 | |||
| 3601 | case 8: | ||
| 3602 | //vlip h | ||
| 3603 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3604 | ✗ | draw_sprite_h_flip(bmp, subBmp, dx, dy); | |
| 3605 | ✗ | break; | |
| 3606 | |||
| 3607 | case 9: | ||
| 3608 | //trans + h flip | ||
| 3609 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3610 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 3611 | ✗ | break; | |
| 3612 | |||
| 3613 | case 10: | ||
| 3614 | //flip H and pivot | ||
| 3615 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3616 | //return error cannot pivot and h flip | ||
| 3617 | ✗ | break; | |
| 3618 | |||
| 3619 | case 12: | ||
| 3620 | //vh flip | ||
| 3621 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3622 | ✗ | draw_sprite_vh_flip(bmp, subBmp, dx, dy); | |
| 3623 | ✗ | break; | |
| 3624 | |||
| 3625 | case 13: | ||
| 3626 | //trans + vh flip | ||
| 3627 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3628 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 3629 | ✗ | break; | |
| 3630 | |||
| 3631 | case 14: | ||
| 3632 | //pivot and vh flip | ||
| 3633 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3634 | //return error cannot both pivot and vh flip | ||
| 3635 | ✗ | break; | |
| 3636 | |||
| 3637 | case 16: | ||
| 3638 | //lit | ||
| 3639 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3640 | ✗ | draw_lit_sprite(bmp, subBmp, dx, dy, litcolour); | |
| 3641 | ✗ | break; | |
| 3642 | |||
| 3643 | case 18: | ||
| 3644 | //pivot, lit | ||
| 3645 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3646 | ✗ | pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3647 | ✗ | break; | |
| 3648 | |||
| 3649 | case 20: | ||
| 3650 | //lit + v flip | ||
| 3651 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3652 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 3653 | ✗ | break; | |
| 3654 | |||
| 3655 | case 22: | ||
| 3656 | //Pivot, vflip, lit | ||
| 3657 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3658 | ✗ | pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 3659 | ✗ | break; | |
| 3660 | |||
| 3661 | case 24: | ||
| 3662 | //lit + h flip | ||
| 3663 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3664 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 3665 | ✗ | break; | |
| 3666 | |||
| 3667 | case 26: | ||
| 3668 | //pivot + lit + hflip | ||
| 3669 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 3670 | //return error cannot pivot, lit, and flip | ||
| 3671 | ✗ | break; | |
| 3672 | |||
| 3673 | case 28: | ||
| 3674 | //lit + vh flip | ||
| 3675 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3676 | ✗ | draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 3677 | ✗ | break; | |
| 3678 | |||
| 3679 | case 32: //gouraud | ||
| 3680 | //Probably not wort supporting. | ||
| 3681 | //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 3682 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3683 | ✗ | break; | |
| 3684 | |||
| 3685 | case 0: | ||
| 3686 | //no effect | ||
| 3687 | ✗ | blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh); | |
| 3688 | ✗ | break; | |
| 3689 | |||
| 3690 | |||
| 3691 | default: | ||
| 3692 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3693 | |||
| 3694 | |||
| 3695 | } | ||
| 3696 | } //end if not rotated | ||
| 3697 | |||
| 3698 | ✗ | if ( rot != 0 ) //if rotated | |
| 3699 | { | ||
| 3700 | ✗ | switch(mode) | |
| 3701 | { | ||
| 3702 | case 1: | ||
| 3703 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent | |
| 3704 | ✗ | rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3705 | |||
| 3706 | ✗ | break; | |
| 3707 | |||
| 3708 | case 2: | ||
| 3709 | //pivot? | ||
| 3710 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3711 | //return an error, cannot both rotate and pivot | ||
| 3712 | ✗ | break; | |
| 3713 | |||
| 3714 | case 3: | ||
| 3715 | //pivot + trans | ||
| 3716 | //return an error, cannot both rotate and pivot | ||
| 3717 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3718 | ✗ | break; | |
| 3719 | |||
| 3720 | case 4: | ||
| 3721 | //flip v | ||
| 3722 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3723 | ✗ | rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3724 | ✗ | break; | |
| 3725 | |||
| 3726 | case 5: | ||
| 3727 | //trans + v flip | ||
| 3728 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3729 | ✗ | rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3730 | ✗ | break; | |
| 3731 | |||
| 3732 | case 6: | ||
| 3733 | //pivot + v flip | ||
| 3734 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3735 | //return an error, cannot both rotate and pivot | ||
| 3736 | ✗ | break; | |
| 3737 | |||
| 3738 | case 8: | ||
| 3739 | //flip h | ||
| 3740 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 3741 | //return an error, cannot both rotate and flip H | ||
| 3742 | ✗ | break; | |
| 3743 | |||
| 3744 | case 9: | ||
| 3745 | //trans + h flip | ||
| 3746 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 3747 | //return an error, cannot rotate and flip a trans sprite | ||
| 3748 | ✗ | break; | |
| 3749 | |||
| 3750 | case 10: | ||
| 3751 | //flip H and pivot | ||
| 3752 | //return error cannot pivot and h flip | ||
| 3753 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 3754 | ✗ | break; | |
| 3755 | |||
| 3756 | case 12: | ||
| 3757 | //vh flip | ||
| 3758 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3759 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3760 | ✗ | break; | |
| 3761 | |||
| 3762 | case 13: | ||
| 3763 | //trans + vh flip | ||
| 3764 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 3765 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 3766 | ✗ | break; | |
| 3767 | |||
| 3768 | case 14: | ||
| 3769 | //pivot and vh flip | ||
| 3770 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3771 | //return error cannot both pivot and vh flip | ||
| 3772 | ✗ | break; | |
| 3773 | |||
| 3774 | case 16: | ||
| 3775 | //lit | ||
| 3776 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3777 | ✗ | rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3778 | ✗ | break; | |
| 3779 | |||
| 3780 | case 18: | ||
| 3781 | //pivot, lit | ||
| 3782 | //return an error, cannot both rotate and pivot | ||
| 3783 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 3784 | ✗ | break; | |
| 3785 | |||
| 3786 | case 20: | ||
| 3787 | //lit + vflip | ||
| 3788 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3789 | ✗ | rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 3790 | ✗ | break; | |
| 3791 | |||
| 3792 | case 22: | ||
| 3793 | //Pivot, vflip, lit | ||
| 3794 | //return an error, cannot both rotate and pivot | ||
| 3795 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 3796 | ✗ | break; | |
| 3797 | |||
| 3798 | case 24: | ||
| 3799 | //lit + h flip | ||
| 3800 | //return an error, cannot both rotate and H flip | ||
| 3801 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 3802 | ✗ | break; | |
| 3803 | |||
| 3804 | case 26: | ||
| 3805 | //pivot + lit + hflip | ||
| 3806 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 3807 | //return error cannot pivot, lit, and flip | ||
| 3808 | ✗ | break; | |
| 3809 | |||
| 3810 | case 28: | ||
| 3811 | //lit + vh flip | ||
| 3812 | //return an error, cannot both rotate and VH flip | ||
| 3813 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 3814 | ✗ | break; | |
| 3815 | |||
| 3816 | case 32: //gouraud | ||
| 3817 | //Probably not wort supporting. | ||
| 3818 | //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 3819 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 3820 | ✗ | break; | |
| 3821 | |||
| 3822 | case 0: | ||
| 3823 | //no effect. | ||
| 3824 | ✗ | blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); | |
| 3825 | ✗ | rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 3826 | ✗ | break; | |
| 3827 | |||
| 3828 | default: | ||
| 3829 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 3830 | |||
| 3831 | } | ||
| 3832 | } //end if rotated | ||
| 3833 | } //end if not masked | ||
| 3834 | } //end if not stretched | ||
| 3835 | |||
| 3836 | //cleanup | ||
| 3837 | ✗ | if(subBmp) | |
| 3838 | { | ||
| 3839 | ✗ | script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap. | |
| 3840 | } | ||
| 3841 | } | ||
| 3842 | |||
| 3843 | |||
| 3844 | ✗ | void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 3845 | { | ||
| 3846 | //sdci[1]=layer | ||
| 3847 | //sdci[2]=pos[12] | ||
| 3848 | //sdci[3]=uv[8] | ||
| 3849 | //sdci[4]=color[4] | ||
| 3850 | //sdci[5]=size[2] | ||
| 3851 | //sdci[6]=flip | ||
| 3852 | //sdci[7]=tile/combo | ||
| 3853 | //sdci[8]=polytype | ||
| 3854 | |||
| 3855 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 3856 | |||
| 3857 | ✗ | if(!v_ptr) | |
| 3858 | { | ||
| 3859 | ✗ | al_trace("Quad3d: Vector pointer is null! Internal error. \n"); | |
| 3860 | ✗ | return; | |
| 3861 | } | ||
| 3862 | |||
| 3863 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 3864 | |||
| 3865 | ✗ | if(v.empty()) | |
| 3866 | ✗ | return; | |
| 3867 | |||
| 3868 | ✗ | int32_t* pos = &v[0]; | |
| 3869 | ✗ | int32_t* uv = &v[12]; | |
| 3870 | ✗ | int32_t* col = &v[20]; | |
| 3871 | ✗ | int32_t* size = &v[24]; | |
| 3872 | |||
| 3873 | ✗ | int32_t w = size[0]; //magic numerical constants... yuck. | |
| 3874 | ✗ | int32_t h = size[1]; | |
| 3875 | ✗ | int32_t flip = (sdci[6]/10000)&3; | |
| 3876 | ✗ | int32_t tile = sdci[7]/10000; | |
| 3877 | ✗ | int32_t polytype = sdci[8]/10000; | |
| 3878 | |||
| 3879 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 3880 | |||
| 3881 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 3882 | { | ||
| 3883 | ✗ | Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 3884 | ✗ | return; //non power of two error | |
| 3885 | } | ||
| 3886 | |||
| 3887 | ✗ | int32_t tex_width = w*16; | |
| 3888 | ✗ | int32_t tex_height = h*16; | |
| 3889 | |||
| 3890 | ✗ | bool mustDestroyBmp = false; | |
| 3891 | ✗ | BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 3892 | |||
| 3893 | ✗ | if(!tex) | |
| 3894 | { | ||
| 3895 | ✗ | mustDestroyBmp = true; | |
| 3896 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 3897 | ✗ | clear_bitmap(tex); | |
| 3898 | } | ||
| 3899 | |||
| 3900 | ✗ | if(tile > 0) // TILE | |
| 3901 | { | ||
| 3902 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip); | |
| 3903 | } | ||
| 3904 | else // COMBO | ||
| 3905 | { | ||
| 3906 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 3907 | ✗ | const int32_t tiletodraw = combo_tile(c, 0, 0); | |
| 3908 | ✗ | flip = flip ^ c.flip; | |
| 3909 | |||
| 3910 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip); | |
| 3911 | } | ||
| 3912 | |||
| 3913 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 3914 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 3915 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 3916 | ✗ | V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] }; | |
| 3917 | |||
| 3918 | ✗ | quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4); | |
| 3919 | |||
| 3920 | ✗ | if(mustDestroyBmp) | |
| 3921 | ✗ | destroy_bitmap(tex); | |
| 3922 | |||
| 3923 | } | ||
| 3924 | |||
| 3925 | |||
| 3926 | |||
| 3927 | ✗ | void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 3928 | { | ||
| 3929 | //sdci[1]=layer | ||
| 3930 | //sdci[2]=pos[9] | ||
| 3931 | //sdci[3]=uv[6] | ||
| 3932 | //sdci[4]=color[3] | ||
| 3933 | //sdci[5]=size[2] | ||
| 3934 | //sdci[6]=flip | ||
| 3935 | //sdci[7]=tile/combo | ||
| 3936 | //sdci[8]=polytype | ||
| 3937 | |||
| 3938 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 3939 | |||
| 3940 | ✗ | if(!v_ptr) | |
| 3941 | { | ||
| 3942 | ✗ | al_trace("Triange3d: Vector pointer is null! Internal error. \n"); | |
| 3943 | ✗ | return; | |
| 3944 | } | ||
| 3945 | |||
| 3946 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 3947 | |||
| 3948 | ✗ | if(v.empty()) | |
| 3949 | ✗ | return; | |
| 3950 | |||
| 3951 | ✗ | int32_t* pos = &v[0]; | |
| 3952 | ✗ | int32_t* uv = &v[9]; | |
| 3953 | ✗ | int32_t* col = &v[15]; | |
| 3954 | ✗ | int32_t* size = &v[18]; | |
| 3955 | |||
| 3956 | ✗ | int32_t w = size[0]; //magic numerical constants... yuck. | |
| 3957 | ✗ | int32_t h = size[1]; | |
| 3958 | ✗ | int32_t flip = (sdci[6]/10000)&3; | |
| 3959 | ✗ | int32_t tile = sdci[7]/10000; | |
| 3960 | ✗ | int32_t polytype = sdci[8]/10000; | |
| 3961 | |||
| 3962 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 3963 | |||
| 3964 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 3965 | { | ||
| 3966 | ✗ | Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 3967 | ✗ | return; //non power of two error | |
| 3968 | } | ||
| 3969 | |||
| 3970 | ✗ | int32_t tex_width = w*16; | |
| 3971 | ✗ | int32_t tex_height = h*16; | |
| 3972 | |||
| 3973 | ✗ | bool mustDestroyBmp = false; | |
| 3974 | ✗ | BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 3975 | |||
| 3976 | ✗ | if(!tex) | |
| 3977 | { | ||
| 3978 | ✗ | mustDestroyBmp = true; | |
| 3979 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 3980 | ✗ | clear_bitmap(tex); | |
| 3981 | } | ||
| 3982 | |||
| 3983 | ✗ | if(tile > 0) // TILE | |
| 3984 | { | ||
| 3985 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip); | |
| 3986 | } | ||
| 3987 | else // COMBO | ||
| 3988 | { | ||
| 3989 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 3990 | ✗ | const int32_t tiletodraw = combo_tile(c, 0, 0); | |
| 3991 | ✗ | flip = flip ^ c.flip; | |
| 3992 | |||
| 3993 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip); | |
| 3994 | } | ||
| 3995 | |||
| 3996 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 3997 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 3998 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 3999 | |||
| 4000 | ✗ | triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3); | |
| 4001 | |||
| 4002 | ✗ | if(mustDestroyBmp) | |
| 4003 | ✗ | destroy_bitmap(tex); | |
| 4004 | |||
| 4005 | } | ||
| 4006 | |||
| 4007 | ✗ | void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4008 | { | ||
| 4009 | //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]); | ||
| 4010 | //sdci[1]=layer | ||
| 4011 | //sdci[2]=x | ||
| 4012 | //sdci[3]=y | ||
| 4013 | //sdci[4]=x2 | ||
| 4014 | //sdci[5]=y2 | ||
| 4015 | //sdci[6]=color | ||
| 4016 | //sdci[7]=scale factor | ||
| 4017 | //sdci[8]=rotation anchor x | ||
| 4018 | //sdci[9]=rotation anchor y | ||
| 4019 | //sdci[10]=rotation angle | ||
| 4020 | //sdci[11]=fill | ||
| 4021 | //sdci[12]=opacity | ||
| 4022 | //sdci[17] Bitmap Pointer | ||
| 4023 | ✗ | if(sdci[7]==0) //scale | |
| 4024 | { | ||
| 4025 | ✗ | return; | |
| 4026 | } | ||
| 4027 | ✗ | if ( sdci[17] <= 0 ) | |
| 4028 | { | ||
| 4029 | ✗ | Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4030 | ✗ | return; | |
| 4031 | } | ||
| 4032 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4033 | ✗ | if ( refbmp == NULL ) return; | |
| 4034 | |||
| 4035 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4036 | |||
| 4037 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4038 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4039 | ✗ | int32_t x2=sdci[4]/10000; | |
| 4040 | ✗ | int32_t y2=sdci[5]/10000; | |
| 4041 | |||
| 4042 | |||
| 4043 | ✗ | if(x1>x2) | |
| 4044 | { | ||
| 4045 | ✗ | zc_swap(x1,x2); | |
| 4046 | } | ||
| 4047 | |||
| 4048 | ✗ | if(y1>y2) | |
| 4049 | { | ||
| 4050 | ✗ | zc_swap(y1,y2); | |
| 4051 | } | ||
| 4052 | |||
| 4053 | ✗ | if(sdci[7] != 10000) | |
| 4054 | { | ||
| 4055 | ✗ | int32_t w=x2-x1+1; | |
| 4056 | ✗ | int32_t h=y2-y1+1; | |
| 4057 | ✗ | int32_t w2=(w*sdci[7])/10000; | |
| 4058 | ✗ | int32_t h2=(h*sdci[7])/10000; | |
| 4059 | ✗ | x1=x1-((w2-w)/2); | |
| 4060 | ✗ | x2=x2+((w2-w)/2); | |
| 4061 | ✗ | y1=y1-((h2-h)/2); | |
| 4062 | ✗ | y2=y2+((h2-h)/2); | |
| 4063 | } | ||
| 4064 | |||
| 4065 | ✗ | int32_t color=sdci[6]/10000; | |
| 4066 | |||
| 4067 | ✗ | if(sdci[12]/10000<=127) //translucent | |
| 4068 | { | ||
| 4069 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4070 | } | ||
| 4071 | |||
| 4072 | ✗ | if(sdci[10]==0) //no rotation | |
| 4073 | { | ||
| 4074 | ✗ | if(sdci[11]) //filled | |
| 4075 | { | ||
| 4076 | ✗ | rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 4077 | } | ||
| 4078 | else //outline | ||
| 4079 | { | ||
| 4080 | ✗ | rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 4081 | } | ||
| 4082 | } | ||
| 4083 | else //rotate | ||
| 4084 | { | ||
| 4085 | int32_t xy[16]; | ||
| 4086 | ✗ | int32_t rx=sdci[8]/10000; | |
| 4087 | ✗ | int32_t ry=sdci[9]/10000; | |
| 4088 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 4089 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 4090 | ✗ | fixed ra=ra1+ra2; | |
| 4091 | ✗ | ra = (ra/360)*256; | |
| 4092 | |||
| 4093 | ✗ | fixed fcosa = fixcos(ra); | |
| 4094 | ✗ | fixed fsina = fixsin(ra); | |
| 4095 | |||
| 4096 | ✗ | xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1 | |
| 4097 | ✗ | xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1 | |
| 4098 | ✗ | xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2 | |
| 4099 | ✗ | xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1 | |
| 4100 | ✗ | xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2 | |
| 4101 | ✗ | xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2 | |
| 4102 | ✗ | xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1 | |
| 4103 | ✗ | xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2 | |
| 4104 | ✗ | xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1 | |
| 4105 | ✗ | xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1 | |
| 4106 | ✗ | xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2 | |
| 4107 | ✗ | xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1 | |
| 4108 | ✗ | xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2 | |
| 4109 | ✗ | xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2 | |
| 4110 | ✗ | xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1 | |
| 4111 | ✗ | xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2 | |
| 4112 | |||
| 4113 | ✗ | if(sdci[11]) //filled | |
| 4114 | { | ||
| 4115 | ✗ | polygon(refbmp, 4, xy, color); | |
| 4116 | } | ||
| 4117 | else //outline | ||
| 4118 | { | ||
| 4119 | ✗ | line(refbmp, xy[0], xy[1], xy[10], xy[11], color); | |
| 4120 | ✗ | line(refbmp, xy[2], xy[3], xy[12], xy[13], color); | |
| 4121 | ✗ | line(refbmp, xy[4], xy[5], xy[14], xy[15], color); | |
| 4122 | ✗ | line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color); | |
| 4123 | } | ||
| 4124 | } | ||
| 4125 | |||
| 4126 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4127 | } | ||
| 4128 | |||
| 4129 | ✗ | void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4130 | { | ||
| 4131 | //sdci[1]=layer | ||
| 4132 | //sdci[2]=x | ||
| 4133 | //sdci[3]=y | ||
| 4134 | //sdci[4]=tile | ||
| 4135 | //sdci[5]=cset | ||
| 4136 | //sdci[6]=width | ||
| 4137 | //sdci[7]=height | ||
| 4138 | //sdci[8]=overlay | ||
| 4139 | //sdci[9]=opacity | ||
| 4140 | |||
| 4141 | ✗ | if ( sdci[17] <= 0 ) | |
| 4142 | { | ||
| 4143 | ✗ | Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4144 | ✗ | return; | |
| 4145 | } | ||
| 4146 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4147 | ✗ | if ( refbmp == NULL ) return; | |
| 4148 | |||
| 4149 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4150 | |||
| 4151 | ✗ | int32_t x=sdci[2]/10000; | |
| 4152 | ✗ | int32_t y=sdci[3]/10000; | |
| 4153 | |||
| 4154 | ✗ | int32_t tile=sdci[4]/10000; | |
| 4155 | ✗ | int32_t cs=sdci[5]/10000; | |
| 4156 | ✗ | int32_t w=sdci[6]/10000; | |
| 4157 | ✗ | int32_t h=sdci[7]/10000; | |
| 4158 | ✗ | bool overlay=sdci[8]; | |
| 4159 | ✗ | bool trans=(sdci[9]/10000<=127); | |
| 4160 | |||
| 4161 | ✗ | frame2x2(refbmp, &QMisc, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans); | |
| 4162 | } | ||
| 4163 | |||
| 4164 | |||
| 4165 | ✗ | void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4166 | { | ||
| 4167 | //sdci[1]=layer | ||
| 4168 | //sdci[2]=x | ||
| 4169 | //sdci[3]=y | ||
| 4170 | //sdci[4]=radius | ||
| 4171 | //sdci[5]=color | ||
| 4172 | //sdci[6]=scale factor | ||
| 4173 | //sdci[7]=rotation anchor x | ||
| 4174 | //sdci[8]=rotation anchor y | ||
| 4175 | //sdci[9]=rotation angle | ||
| 4176 | //sdci[10]=fill | ||
| 4177 | //sdci[11]=opacity | ||
| 4178 | //sdci[17] Bitmap Pointer | ||
| 4179 | ✗ | if(sdci[6]==0) //scale | |
| 4180 | { | ||
| 4181 | ✗ | return; | |
| 4182 | } | ||
| 4183 | ✗ | if ( sdci[17] <= 0 ) | |
| 4184 | { | ||
| 4185 | ✗ | Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4186 | ✗ | return; | |
| 4187 | } | ||
| 4188 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4189 | ✗ | if ( refbmp == NULL ) return; | |
| 4190 | |||
| 4191 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4192 | |||
| 4193 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4194 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4195 | ✗ | qword r=sdci[4]; | |
| 4196 | |||
| 4197 | ✗ | if(sdci[6] != 10000) | |
| 4198 | { | ||
| 4199 | ✗ | r*=sdci[6]; | |
| 4200 | ✗ | r/=10000; | |
| 4201 | } | ||
| 4202 | |||
| 4203 | ✗ | r/=10000; | |
| 4204 | ✗ | int32_t color=sdci[5]/10000; | |
| 4205 | |||
| 4206 | ✗ | if(sdci[11]/10000<=127) //translucent | |
| 4207 | { | ||
| 4208 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4209 | } | ||
| 4210 | |||
| 4211 | ✗ | if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation | |
| 4212 | { | ||
| 4213 | int32_t xy[2]; | ||
| 4214 | ✗ | int32_t rx=sdci[7]/10000; | |
| 4215 | ✗ | int32_t ry=sdci[8]/10000; | |
| 4216 | ✗ | fixed ra1=itofix(sdci[9]%10000)/10000; | |
| 4217 | ✗ | fixed ra2=itofix(sdci[9]/10000); | |
| 4218 | ✗ | fixed ra=ra1+ra2; | |
| 4219 | ✗ | ra = (ra/360)*256; | |
| 4220 | |||
| 4221 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4222 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4223 | ✗ | x1=xy[0]; | |
| 4224 | ✗ | y1=xy[1]; | |
| 4225 | } | ||
| 4226 | |||
| 4227 | ✗ | if(sdci[10]) //filled | |
| 4228 | { | ||
| 4229 | ✗ | circlefill(refbmp, x1+xoffset, y1+yoffset, r, color); | |
| 4230 | } | ||
| 4231 | else //outline | ||
| 4232 | { | ||
| 4233 | ✗ | circle(refbmp, x1+xoffset, y1+yoffset, r, color); | |
| 4234 | } | ||
| 4235 | |||
| 4236 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4237 | } | ||
| 4238 | |||
| 4239 | |||
| 4240 | ✗ | void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4241 | { | ||
| 4242 | //sdci[1]=layer | ||
| 4243 | //sdci[2]=x | ||
| 4244 | //sdci[3]=y | ||
| 4245 | //sdci[4]=radius | ||
| 4246 | //sdci[5]=start angle | ||
| 4247 | //sdci[6]=end angle | ||
| 4248 | //sdci[7]=color | ||
| 4249 | //sdci[8]=scale factor | ||
| 4250 | //sdci[9]=rotation anchor x | ||
| 4251 | //sdci[10]=rotation anchor y | ||
| 4252 | //sdci[11]=rotation angle | ||
| 4253 | //sdci[12]=closed | ||
| 4254 | //sdci[13]=fill | ||
| 4255 | //sdci[14]=opacity | ||
| 4256 | //sdci[17] Bitmap Pointer | ||
| 4257 | |||
| 4258 | ✗ | if(sdci[8]==0) //scale | |
| 4259 | { | ||
| 4260 | ✗ | return; | |
| 4261 | } | ||
| 4262 | ✗ | if ( sdci[17] <= 0 ) | |
| 4263 | { | ||
| 4264 | ✗ | Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4265 | ✗ | return; | |
| 4266 | } | ||
| 4267 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4268 | ✗ | if ( refbmp == NULL ) return; | |
| 4269 | |||
| 4270 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4271 | |||
| 4272 | ✗ | int32_t cx=sdci[2]/10000; | |
| 4273 | ✗ | int32_t cy=sdci[3]/10000; | |
| 4274 | ✗ | qword r=sdci[4]; | |
| 4275 | |||
| 4276 | ✗ | if(sdci[8] != 10000) | |
| 4277 | { | ||
| 4278 | ✗ | r*=sdci[8]; | |
| 4279 | ✗ | r/=10000; | |
| 4280 | } | ||
| 4281 | |||
| 4282 | ✗ | r/=10000; | |
| 4283 | |||
| 4284 | ✗ | int32_t color=sdci[7]/10000; | |
| 4285 | |||
| 4286 | ✗ | fixed ra1=itofix(sdci[11]%10000)/10000; | |
| 4287 | ✗ | fixed ra2=itofix(sdci[11]/10000); | |
| 4288 | ✗ | fixed ra=ra1+ra2; | |
| 4289 | ✗ | ra = (ra/360)*256; | |
| 4290 | |||
| 4291 | |||
| 4292 | ✗ | fixed a1=itofix(sdci[5]%10000)/10000; | |
| 4293 | ✗ | fixed a2=itofix(sdci[5]/10000); | |
| 4294 | ✗ | fixed sa=a1+a2; | |
| 4295 | ✗ | sa = (sa/360)*256; | |
| 4296 | |||
| 4297 | ✗ | a1=itofix(sdci[6]%10000)/10000; | |
| 4298 | ✗ | a2=itofix(sdci[6]/10000); | |
| 4299 | ✗ | fixed ea=a1+a2; | |
| 4300 | ✗ | ea = (ea/360)*256; | |
| 4301 | |||
| 4302 | ✗ | if(sdci[11]!=0) //rotation | |
| 4303 | { | ||
| 4304 | ✗ | int32_t rx=sdci[9]/10000; | |
| 4305 | ✗ | int32_t ry=sdci[10]/10000; | |
| 4306 | |||
| 4307 | ✗ | cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1 | |
| 4308 | ✗ | cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1 | |
| 4309 | ✗ | ea-=ra; | |
| 4310 | ✗ | sa-=ra; | |
| 4311 | } | ||
| 4312 | |||
| 4313 | ✗ | int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2); | |
| 4314 | ✗ | int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2); | |
| 4315 | |||
| 4316 | ✗ | if(sdci[12]) //closed | |
| 4317 | { | ||
| 4318 | ✗ | if(sdci[13]) //filled | |
| 4319 | { | ||
| 4320 | ✗ | clear_bitmap(prim_bmp); | |
| 4321 | ✗ | arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 4322 | ✗ | line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color); | |
| 4323 | ✗ | line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color); | |
| 4324 | ✗ | floodfill(prim_bmp, zc_max(0,fx)+xoffset, zc_max(0,fy)+yoffset, color); | |
| 4325 | |||
| 4326 | ✗ | if(sdci[14]/10000<=127) //translucent | |
| 4327 | { | ||
| 4328 | ✗ | draw_trans_sprite(refbmp, prim_bmp, 0,0); | |
| 4329 | } | ||
| 4330 | else | ||
| 4331 | { | ||
| 4332 | ✗ | draw_sprite(refbmp, prim_bmp, 0,0); | |
| 4333 | } | ||
| 4334 | } | ||
| 4335 | else | ||
| 4336 | { | ||
| 4337 | ✗ | arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 4338 | ✗ | line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color); | |
| 4339 | ✗ | line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color); | |
| 4340 | } | ||
| 4341 | } | ||
| 4342 | else | ||
| 4343 | { | ||
| 4344 | ✗ | if(sdci[14]/10000<=127) //translucent | |
| 4345 | { | ||
| 4346 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4347 | } | ||
| 4348 | |||
| 4349 | ✗ | arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color); | |
| 4350 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4351 | } | ||
| 4352 | } | ||
| 4353 | |||
| 4354 | |||
| 4355 | ✗ | void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4356 | { | ||
| 4357 | //sdci[1]=layer | ||
| 4358 | //sdci[2]=x | ||
| 4359 | //sdci[3]=y | ||
| 4360 | //sdci[4]=radiusx | ||
| 4361 | //sdci[5]=radiusy | ||
| 4362 | //sdci[6]=color | ||
| 4363 | //sdci[7]=scale factor | ||
| 4364 | //sdci[8]=rotation anchor x | ||
| 4365 | //sdci[9]=rotation anchor y | ||
| 4366 | //sdci[10]=rotation angle | ||
| 4367 | //sdci[11]=fill | ||
| 4368 | //sdci[12]=opacity | ||
| 4369 | //sdci[17] Bitmap Pointer | ||
| 4370 | |||
| 4371 | ✗ | if(sdci[7]==0) //scale | |
| 4372 | { | ||
| 4373 | ✗ | return; | |
| 4374 | } | ||
| 4375 | ✗ | if ( sdci[17] <= 0 ) | |
| 4376 | { | ||
| 4377 | ✗ | Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4378 | ✗ | return; | |
| 4379 | } | ||
| 4380 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4381 | ✗ | if ( refbmp == NULL ) return; | |
| 4382 | |||
| 4383 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4384 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4385 | ✗ | int32_t radx=sdci[4]/10000; | |
| 4386 | ✗ | radx*=sdci[7]/10000; | |
| 4387 | ✗ | int32_t rady=sdci[5]/10000; | |
| 4388 | ✗ | rady*=sdci[7]/10000; | |
| 4389 | ✗ | int32_t color=sdci[6]/10000; | |
| 4390 | ✗ | float rotation = sdci[10]/10000; | |
| 4391 | |||
| 4392 | ✗ | int32_t rx=sdci[8]/10000; | |
| 4393 | ✗ | int32_t ry=sdci[9]/10000; | |
| 4394 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 4395 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 4396 | ✗ | fixed ra=ra1+ra2; | |
| 4397 | ✗ | ra = (ra/360)*256; | |
| 4398 | |||
| 4399 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4400 | |||
| 4401 | int32_t xy[2]; | ||
| 4402 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4403 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4404 | ✗ | x1=xy[0]; | |
| 4405 | ✗ | y1=xy[1]; | |
| 4406 | |||
| 4407 | ✗ | if(radx<1||rady<1||radx>255||rady>255) return; | |
| 4408 | |||
| 4409 | ✗ | BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1); | |
| 4410 | |||
| 4411 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4412 | |||
| 4413 | ✗ | if(sdci[11]) //filled | |
| 4414 | { | ||
| 4415 | |||
| 4416 | ✗ | if(sdci[12]/10000<128) //translucent | |
| 4417 | { | ||
| 4418 | ✗ | clear_bitmap(prim_bmp); | |
| 4419 | ✗ | ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 4420 | ✗ | rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 4421 | ✗ | draw_trans_sprite(refbmp, prim_bmp, 0, 0); | |
| 4422 | } | ||
| 4423 | else // no opacity | ||
| 4424 | { | ||
| 4425 | ✗ | ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 4426 | ✗ | rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 4427 | } | ||
| 4428 | } | ||
| 4429 | else //not filled | ||
| 4430 | { | ||
| 4431 | ✗ | if(sdci[12]/10000<128) //translucent | |
| 4432 | { | ||
| 4433 | ✗ | clear_bitmap(prim_bmp); | |
| 4434 | ✗ | ellipse(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 4435 | ✗ | rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 4436 | ✗ | draw_trans_sprite(refbmp, prim_bmp, 0, 0); | |
| 4437 | } | ||
| 4438 | else // no opacity | ||
| 4439 | { | ||
| 4440 | ✗ | ellipse(bitty, radx, rady, radx, rady, color==0?255:color); | |
| 4441 | ✗ | rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation)); | |
| 4442 | } | ||
| 4443 | } | ||
| 4444 | |||
| 4445 | // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0. | ||
| 4446 | // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around | ||
| 4447 | // the ellipse, but it shouldn't be used anyway. | ||
| 4448 | ✗ | if(color==0) | |
| 4449 | { | ||
| 4450 | // This is very slow, so check the smallest possible square | ||
| 4451 | ✗ | int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady)); | |
| 4452 | ✗ | int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady)); | |
| 4453 | |||
| 4454 | ✗ | for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++) | |
| 4455 | ✗ | for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++) | |
| 4456 | ✗ | if(getpixel(refbmp, x, y)==255) | |
| 4457 | ✗ | putpixel(refbmp, x, y, 0); | |
| 4458 | } | ||
| 4459 | |||
| 4460 | ✗ | script_drawing_commands.ReleaseSubBitmap(bitty); | |
| 4461 | } | ||
| 4462 | |||
| 4463 | |||
| 4464 | ✗ | void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4465 | { | ||
| 4466 | //sdci[1]=layer | ||
| 4467 | //sdci[2]=x | ||
| 4468 | //sdci[3]=y | ||
| 4469 | //sdci[4]=x2 | ||
| 4470 | //sdci[5]=y2 | ||
| 4471 | //sdci[6]=color | ||
| 4472 | //sdci[7]=scale factor | ||
| 4473 | //sdci[8]=rotation anchor x | ||
| 4474 | //sdci[9]=rotation anchor y | ||
| 4475 | //sdci[10]=rotation angle | ||
| 4476 | //sdci[11]=opacity | ||
| 4477 | //sdci[17] Bitmap Pointer | ||
| 4478 | ✗ | if(sdci[7]==0) //scale | |
| 4479 | { | ||
| 4480 | ✗ | return; | |
| 4481 | } | ||
| 4482 | |||
| 4483 | ✗ | if ( sdci[17] <= 0 ) | |
| 4484 | { | ||
| 4485 | ✗ | Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4486 | ✗ | return; | |
| 4487 | } | ||
| 4488 | |||
| 4489 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4490 | ✗ | if ( refbmp == NULL ) return; | |
| 4491 | |||
| 4492 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4493 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4494 | ✗ | int32_t x2=sdci[4]/10000; | |
| 4495 | ✗ | int32_t y2=sdci[5]/10000; | |
| 4496 | |||
| 4497 | ✗ | if(sdci[7] != 10000) | |
| 4498 | { | ||
| 4499 | ✗ | int32_t w=x2-x1+1; | |
| 4500 | ✗ | int32_t h=y2-y1+1; | |
| 4501 | ✗ | int32_t w2=int32_t(w*((double)sdci[7]/10000.0)); | |
| 4502 | ✗ | int32_t h2=int32_t(h*((double)sdci[7]/10000.0)); | |
| 4503 | ✗ | x1=x1-((w2-w)/2); | |
| 4504 | ✗ | x2=x2+((w2-w)/2); | |
| 4505 | ✗ | y1=y1-((h2-h)/2); | |
| 4506 | ✗ | y2=y2+((h2-h)/2); | |
| 4507 | } | ||
| 4508 | |||
| 4509 | ✗ | int32_t color=sdci[6]/10000; | |
| 4510 | |||
| 4511 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4512 | |||
| 4513 | ✗ | if(sdci[11]/10000<=127) //translucent | |
| 4514 | { | ||
| 4515 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4516 | } | ||
| 4517 | |||
| 4518 | ✗ | if(sdci[10]!=0) //rotation | |
| 4519 | { | ||
| 4520 | int32_t xy[4]; | ||
| 4521 | ✗ | int32_t rx=sdci[8]/10000; | |
| 4522 | ✗ | int32_t ry=sdci[9]/10000; | |
| 4523 | ✗ | fixed ra1=itofix(sdci[10]%10000)/10000; | |
| 4524 | ✗ | fixed ra2=itofix(sdci[10]/10000); | |
| 4525 | ✗ | fixed ra=ra1+ra2; | |
| 4526 | |||
| 4527 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4528 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4529 | ✗ | xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2 | |
| 4530 | ✗ | xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2 | |
| 4531 | ✗ | x1=xy[0]; | |
| 4532 | ✗ | y1=xy[1]; | |
| 4533 | ✗ | x2=xy[2]; | |
| 4534 | ✗ | y2=xy[3]; | |
| 4535 | } | ||
| 4536 | |||
| 4537 | ✗ | line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color); | |
| 4538 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4539 | } | ||
| 4540 | |||
| 4541 | |||
| 4542 | ✗ | void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4543 | { | ||
| 4544 | /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */ | ||
| 4545 | //sdci[17] Bitmap Pointer | ||
| 4546 | |||
| 4547 | ✗ | int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000), | |
| 4548 | ✗ | xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000), | |
| 4549 | ✗ | xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000), | |
| 4550 | ✗ | xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000) | |
| 4551 | }; | ||
| 4552 | |||
| 4553 | ✗ | if(sdci[11]/10000 < 128) //translucent | |
| 4554 | { | ||
| 4555 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4556 | } | ||
| 4557 | |||
| 4558 | ✗ | if ( sdci[17] <= 0 ) | |
| 4559 | { | ||
| 4560 | ✗ | Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4561 | ✗ | return; | |
| 4562 | } | ||
| 4563 | |||
| 4564 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4565 | ✗ | if ( refbmp == NULL ) return; | |
| 4566 | |||
| 4567 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4568 | |||
| 4569 | ✗ | spline(refbmp, points, sdci[10]/10000); | |
| 4570 | |||
| 4571 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4572 | } | ||
| 4573 | |||
| 4574 | |||
| 4575 | ✗ | void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4576 | { | ||
| 4577 | //sdci[1]=layer | ||
| 4578 | //sdci[2]=x | ||
| 4579 | //sdci[3]=y | ||
| 4580 | //sdci[4]=color | ||
| 4581 | //sdci[5]=rotation anchor x | ||
| 4582 | //sdci[6]=rotation anchor y | ||
| 4583 | //sdci[7]=rotation angle | ||
| 4584 | //sdci[8]=opacity | ||
| 4585 | //sdci[17] Bitmap Pointer | ||
| 4586 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4587 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4588 | ✗ | int32_t color=sdci[4]/10000; | |
| 4589 | |||
| 4590 | ✗ | if(sdci[8]/10000<=127) //translucent | |
| 4591 | { | ||
| 4592 | ✗ | drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); | |
| 4593 | } | ||
| 4594 | |||
| 4595 | ✗ | if ( sdci[17] <= 0 ) | |
| 4596 | { | ||
| 4597 | ✗ | Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4598 | ✗ | return; | |
| 4599 | } | ||
| 4600 | |||
| 4601 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4602 | ✗ | if ( refbmp == NULL ) return; | |
| 4603 | |||
| 4604 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4605 | |||
| 4606 | ✗ | if(sdci[7]!=0) //rotation | |
| 4607 | { | ||
| 4608 | int32_t xy[2]; | ||
| 4609 | ✗ | int32_t rx=sdci[5]/10000; | |
| 4610 | ✗ | int32_t ry=sdci[6]/10000; | |
| 4611 | ✗ | fixed ra1=itofix(sdci[7]%10000)/10000; | |
| 4612 | ✗ | fixed ra2=itofix(sdci[7]/10000); | |
| 4613 | ✗ | fixed ra=ra1+ra2; | |
| 4614 | |||
| 4615 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4616 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4617 | ✗ | x1=xy[0]; | |
| 4618 | ✗ | y1=xy[1]; | |
| 4619 | } | ||
| 4620 | |||
| 4621 | ✗ | putpixel(refbmp, x1+xoffset, y1+yoffset, color); | |
| 4622 | ✗ | drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); | |
| 4623 | } | ||
| 4624 | |||
| 4625 | |||
| 4626 | ✗ | void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4627 | { | ||
| 4628 | //sdci[1]=layer | ||
| 4629 | //sdci[2]=x | ||
| 4630 | //sdci[3]=y | ||
| 4631 | //sdci[4]=tile | ||
| 4632 | //sdci[5]=tile width | ||
| 4633 | //sdci[6]=tile height | ||
| 4634 | //sdci[7]=color (cset) | ||
| 4635 | //sdci[8]=scale x | ||
| 4636 | //sdci[9]=scale y | ||
| 4637 | //sdci[10]=rotation anchor x | ||
| 4638 | //sdci[11]=rotation anchor y | ||
| 4639 | //sdci[12]=rotation angle | ||
| 4640 | //sdci[13]=flip | ||
| 4641 | //sdci[14]=transparency | ||
| 4642 | //sdci[15]=opacity | ||
| 4643 | //sdci[17] Bitmap Pointer | ||
| 4644 | |||
| 4645 | ✗ | int32_t w = sdci[5]/10000; | |
| 4646 | ✗ | int32_t h = sdci[6]/10000; | |
| 4647 | |||
| 4648 | ✗ | if(w < 1 || h < 1 || h > 20 || w > 20) | |
| 4649 | { | ||
| 4650 | ✗ | return; | |
| 4651 | } | ||
| 4652 | |||
| 4653 | ✗ | if ( sdci[17] <= 0 ) | |
| 4654 | { | ||
| 4655 | ✗ | Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4656 | ✗ | return; | |
| 4657 | } | ||
| 4658 | |||
| 4659 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4660 | ✗ | if ( refbmp == NULL ) return; | |
| 4661 | |||
| 4662 | ✗ | int32_t xscale=sdci[8]/10000; | |
| 4663 | ✗ | int32_t yscale=sdci[9]/10000; | |
| 4664 | ✗ | int32_t rx = sdci[10]/10000; | |
| 4665 | ✗ | int32_t ry = sdci[11]/10000; | |
| 4666 | ✗ | float rotation=sdci[12]/10000; | |
| 4667 | ✗ | int32_t flip=(sdci[13]/10000)&3; | |
| 4668 | ✗ | bool transparency=sdci[14]!=0; | |
| 4669 | ✗ | int32_t opacity=sdci[15]/10000; | |
| 4670 | ✗ | int32_t color=sdci[7]/10000; | |
| 4671 | |||
| 4672 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4673 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4674 | |||
| 4675 | |||
| 4676 | //don't scale if it's not safe to do so | ||
| 4677 | ✗ | bool canscale = true; | |
| 4678 | |||
| 4679 | ✗ | if(xscale==0||yscale==0) | |
| 4680 | { | ||
| 4681 | ✗ | return; | |
| 4682 | } | ||
| 4683 | |||
| 4684 | ✗ | if(xscale<0||yscale<0) | |
| 4685 | ✗ | canscale = false; //default size | |
| 4686 | |||
| 4687 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4688 | |||
| 4689 | ✗ | if((xscale>0 && yscale>0) || rotation) //scaled or rotated | |
| 4690 | { | ||
| 4691 | ✗ | BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); | |
| 4692 | |||
| 4693 | ✗ | if(transparency) //transparency | |
| 4694 | { | ||
| 4695 | ✗ | TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip); | |
| 4696 | } | ||
| 4697 | else //no transparency | ||
| 4698 | { | ||
| 4699 | ✗ | TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip); | |
| 4700 | } | ||
| 4701 | |||
| 4702 | ✗ | if(rotation != 0) | |
| 4703 | { | ||
| 4704 | //low negative values indicate no anchor-point rotation | ||
| 4705 | ✗ | if(rx>-777||ry>-777) | |
| 4706 | { | ||
| 4707 | int32_t xy[2]; | ||
| 4708 | ✗ | fixed ra1=itofix(sdci[12]%10000)/10000; | |
| 4709 | ✗ | fixed ra2=itofix(sdci[12]/10000); | |
| 4710 | ✗ | fixed ra=ra1+ra2; | |
| 4711 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4712 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4713 | ✗ | x1=xy[0]; | |
| 4714 | ✗ | y1=xy[1]; | |
| 4715 | } | ||
| 4716 | |||
| 4717 | ✗ | if(canscale) //scale first | |
| 4718 | { | ||
| 4719 | //damnit all, .. fixme. | ||
| 4720 | ✗ | BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale); | |
| 4721 | ✗ | clear_bitmap(tempbit); | |
| 4722 | |||
| 4723 | ✗ | stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale); | |
| 4724 | |||
| 4725 | ✗ | if(opacity < 128) | |
| 4726 | { | ||
| 4727 | ✗ | clear_bitmap(prim_bmp); | |
| 4728 | ✗ | rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation)); | |
| 4729 | ✗ | draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4730 | } | ||
| 4731 | else | ||
| 4732 | { | ||
| 4733 | ✗ | rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 4734 | } | ||
| 4735 | |||
| 4736 | ✗ | destroy_bitmap(tempbit); | |
| 4737 | } | ||
| 4738 | else //no scale | ||
| 4739 | { | ||
| 4740 | ✗ | if(opacity < 128) | |
| 4741 | { | ||
| 4742 | ✗ | clear_bitmap(prim_bmp); | |
| 4743 | ✗ | rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation)); | |
| 4744 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4745 | } | ||
| 4746 | else | ||
| 4747 | { | ||
| 4748 | ✗ | rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 4749 | } | ||
| 4750 | } | ||
| 4751 | } | ||
| 4752 | else //scale only | ||
| 4753 | { | ||
| 4754 | ✗ | if(canscale) | |
| 4755 | { | ||
| 4756 | ✗ | if(opacity<128) | |
| 4757 | { | ||
| 4758 | ✗ | clear_bitmap(prim_bmp); | |
| 4759 | ✗ | stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale); | |
| 4760 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4761 | } | ||
| 4762 | else | ||
| 4763 | { | ||
| 4764 | ✗ | stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale); | |
| 4765 | } | ||
| 4766 | } | ||
| 4767 | else //error -do not scale | ||
| 4768 | { | ||
| 4769 | ✗ | if(opacity<128) | |
| 4770 | { | ||
| 4771 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4772 | } | ||
| 4773 | else | ||
| 4774 | { | ||
| 4775 | ✗ | draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset); | |
| 4776 | } | ||
| 4777 | } | ||
| 4778 | } | ||
| 4779 | |||
| 4780 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbitty); | |
| 4781 | |||
| 4782 | } | ||
| 4783 | else // no scale or rotation | ||
| 4784 | { | ||
| 4785 | ✗ | if(transparency) | |
| 4786 | { | ||
| 4787 | ✗ | if(opacity<=127) | |
| 4788 | ✗ | TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity); | |
| 4789 | else | ||
| 4790 | ✗ | TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip); | |
| 4791 | } | ||
| 4792 | else | ||
| 4793 | { | ||
| 4794 | ✗ | if(opacity<=127) | |
| 4795 | ✗ | TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity); | |
| 4796 | else | ||
| 4797 | ✗ | TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip); | |
| 4798 | } | ||
| 4799 | } | ||
| 4800 | } | ||
| 4801 | |||
| 4802 | ✗ | void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4803 | { | ||
| 4804 | //sdci[1]=layer | ||
| 4805 | //sdci[2]=x | ||
| 4806 | //sdci[3]=y | ||
| 4807 | //sdci[4]=tile | ||
| 4808 | //sdci[5]=tile width | ||
| 4809 | //sdci[6]=tile height | ||
| 4810 | //sdci[7]=flip | ||
| 4811 | //sdci[17] Bitmap Pointer | ||
| 4812 | |||
| 4813 | ✗ | int32_t w = sdci[5]/10000; | |
| 4814 | ✗ | int32_t h = sdci[6]/10000; | |
| 4815 | |||
| 4816 | ✗ | if(w < 1 || h < 1 || h > 20 || w > 20) | |
| 4817 | { | ||
| 4818 | ✗ | return; | |
| 4819 | } | ||
| 4820 | |||
| 4821 | ✗ | if ( sdci[17] <= 0 ) | |
| 4822 | { | ||
| 4823 | ✗ | Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4824 | ✗ | return; | |
| 4825 | } | ||
| 4826 | |||
| 4827 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4828 | ✗ | if ( refbmp == NULL ) return; | |
| 4829 | |||
| 4830 | ✗ | int32_t flip=(sdci[7]/10000)&3; | |
| 4831 | |||
| 4832 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4833 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4834 | |||
| 4835 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4836 | |||
| 4837 | ✗ | TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip); | |
| 4838 | } | ||
| 4839 | |||
| 4840 | |||
| 4841 | ✗ | void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 4842 | { | ||
| 4843 | //sdci[1]=layer | ||
| 4844 | //sdci[2]=x | ||
| 4845 | //sdci[3]=y | ||
| 4846 | //sdci[4]=combo | ||
| 4847 | //sdci[5]=tile width | ||
| 4848 | //sdci[6]=tile height | ||
| 4849 | //sdci[7]=color (cset) | ||
| 4850 | //sdci[8]=scale x | ||
| 4851 | //sdci[9]=scale y | ||
| 4852 | //sdci[10]=rotation anchor x | ||
| 4853 | //sdci[11]=rotation anchor y | ||
| 4854 | //sdci[12]=rotation angle | ||
| 4855 | //sdci[13]=frame | ||
| 4856 | //sdci[14]=flip | ||
| 4857 | //sdci[15]=transparency | ||
| 4858 | //sdci[16]=opacity | ||
| 4859 | //sdci[17] Bitmap Pointer | ||
| 4860 | ✗ | int32_t w = sdci[5]/10000; | |
| 4861 | ✗ | int32_t h = sdci[6]/10000; | |
| 4862 | |||
| 4863 | ✗ | if(w<1||h<1||h>20||w>20) | |
| 4864 | { | ||
| 4865 | ✗ | return; | |
| 4866 | } | ||
| 4867 | |||
| 4868 | ✗ | if ( sdci[17] <= 0 ) | |
| 4869 | { | ||
| 4870 | ✗ | Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 4871 | ✗ | return; | |
| 4872 | } | ||
| 4873 | |||
| 4874 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 4875 | ✗ | if ( refbmp == NULL ) return; | |
| 4876 | ✗ | int32_t cmb = (sdci[4]/10000); | |
| 4877 | ✗ | if((unsigned)cmb >= MAXCOMBOS) | |
| 4878 | { | ||
| 4879 | ✗ | Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 4880 | ✗ | return; | |
| 4881 | } | ||
| 4882 | |||
| 4883 | ✗ | int32_t xscale=sdci[8]/10000; | |
| 4884 | ✗ | int32_t yscale=sdci[9]/10000; | |
| 4885 | ✗ | int32_t rx = sdci[10]/10000; //these work now | |
| 4886 | ✗ | int32_t ry = sdci[11]/10000; //these work now | |
| 4887 | ✗ | float rotation=sdci[12]/10000; | |
| 4888 | |||
| 4889 | ✗ | bool transparency=sdci[15]!=0; | |
| 4890 | ✗ | int32_t opacity=sdci[16]/10000; | |
| 4891 | ✗ | int32_t color=sdci[7]/10000; | |
| 4892 | ✗ | int32_t x1=sdci[2]/10000; | |
| 4893 | ✗ | int32_t y1=sdci[3]/10000; | |
| 4894 | |||
| 4895 | ✗ | const newcombo & c = combobuf[cmb]; | |
| 4896 | ✗ | int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 4897 | ✗ | int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip; | |
| 4898 | ✗ | int32_t skiprows=c.skipanimy; | |
| 4899 | |||
| 4900 | |||
| 4901 | //don't scale if it's not safe to do so | ||
| 4902 | ✗ | bool canscale = true; | |
| 4903 | |||
| 4904 | ✗ | if(xscale==0||yscale==0) | |
| 4905 | { | ||
| 4906 | ✗ | return; | |
| 4907 | } | ||
| 4908 | |||
| 4909 | ✗ | if(xscale<0||yscale<0) | |
| 4910 | ✗ | canscale = false; //default size | |
| 4911 | |||
| 4912 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 4913 | |||
| 4914 | ✗ | if((xscale>0 && yscale>0) || rotation) //scaled or rotated | |
| 4915 | { | ||
| 4916 | ✗ | BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D | |
| 4917 | |||
| 4918 | ✗ | if(transparency) | |
| 4919 | { | ||
| 4920 | ✗ | TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows); | |
| 4921 | } | ||
| 4922 | else //no transparency | ||
| 4923 | { | ||
| 4924 | ✗ | TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows); | |
| 4925 | } | ||
| 4926 | |||
| 4927 | ✗ | if(rotation != 0) // rotate | |
| 4928 | { | ||
| 4929 | //fixed point sucks ;0 | ||
| 4930 | ✗ | if(rx>-777||ry>-777) //set the rotation anchor and rotate around that | |
| 4931 | { | ||
| 4932 | int32_t xy[2]; | ||
| 4933 | ✗ | fixed ra1=itofix(sdci[12]%10000)/10000; | |
| 4934 | ✗ | fixed ra2=itofix(sdci[12]/10000); | |
| 4935 | ✗ | fixed ra=ra1+ra2; | |
| 4936 | ✗ | xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1 | |
| 4937 | ✗ | xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1 | |
| 4938 | ✗ | x1=xy[0]; | |
| 4939 | ✗ | y1=xy[1]; | |
| 4940 | } | ||
| 4941 | |||
| 4942 | ✗ | if(canscale) //scale first | |
| 4943 | { | ||
| 4944 | ✗ | BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale); | |
| 4945 | ✗ | clear_bitmap(tempbit); | |
| 4946 | |||
| 4947 | ✗ | stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale); | |
| 4948 | |||
| 4949 | ✗ | if(opacity < 128) | |
| 4950 | { | ||
| 4951 | ✗ | clear_bitmap(prim_bmp); | |
| 4952 | ✗ | rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation)); | |
| 4953 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4954 | } | ||
| 4955 | else | ||
| 4956 | { | ||
| 4957 | ✗ | rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 4958 | } | ||
| 4959 | |||
| 4960 | ✗ | destroy_bitmap(tempbit); | |
| 4961 | } | ||
| 4962 | else //no scale | ||
| 4963 | { | ||
| 4964 | ✗ | if(opacity < 128) | |
| 4965 | { | ||
| 4966 | ✗ | clear_bitmap(prim_bmp); | |
| 4967 | ✗ | rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation)); | |
| 4968 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4969 | } | ||
| 4970 | else | ||
| 4971 | { | ||
| 4972 | ✗ | rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation)); | |
| 4973 | } | ||
| 4974 | } | ||
| 4975 | } | ||
| 4976 | else //scale only | ||
| 4977 | { | ||
| 4978 | ✗ | if(canscale) | |
| 4979 | { | ||
| 4980 | ✗ | if(opacity<128) | |
| 4981 | { | ||
| 4982 | ✗ | clear_bitmap(prim_bmp); | |
| 4983 | ✗ | stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale); | |
| 4984 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4985 | } | ||
| 4986 | else | ||
| 4987 | { | ||
| 4988 | ✗ | stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale); | |
| 4989 | } | ||
| 4990 | } | ||
| 4991 | else //error -do not scale | ||
| 4992 | { | ||
| 4993 | ✗ | if(opacity<128) | |
| 4994 | { | ||
| 4995 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset); | |
| 4996 | } | ||
| 4997 | else | ||
| 4998 | { | ||
| 4999 | ✗ | draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset); | |
| 5000 | } | ||
| 5001 | } | ||
| 5002 | } | ||
| 5003 | |||
| 5004 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks | |
| 5005 | } | ||
| 5006 | else // no scale or rotation | ||
| 5007 | { | ||
| 5008 | ✗ | if(transparency) | |
| 5009 | { | ||
| 5010 | ✗ | if(opacity<=127) | |
| 5011 | ✗ | TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows); | |
| 5012 | else | ||
| 5013 | ✗ | TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows); | |
| 5014 | } | ||
| 5015 | else | ||
| 5016 | { | ||
| 5017 | ✗ | if(opacity<=127) | |
| 5018 | ✗ | TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows); | |
| 5019 | else | ||
| 5020 | ✗ | TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows); | |
| 5021 | } | ||
| 5022 | } | ||
| 5023 | } | ||
| 5024 | |||
| 5025 | |||
| 5026 | ✗ | void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5027 | { | ||
| 5028 | //sdci[1]=layer | ||
| 5029 | //sdci[2]=x | ||
| 5030 | //sdci[3]=y | ||
| 5031 | //sdci[4]=combo | ||
| 5032 | //sdci[5]=tile width | ||
| 5033 | //sdci[6]=tile height | ||
| 5034 | //sdci[7]=flip | ||
| 5035 | //sdci[17] Bitmap Pointer | ||
| 5036 | |||
| 5037 | ✗ | int32_t w = sdci[5]/10000; | |
| 5038 | ✗ | int32_t h = sdci[6]/10000; | |
| 5039 | |||
| 5040 | ✗ | if(w<1||h<1||h>20||w>20) | |
| 5041 | { | ||
| 5042 | ✗ | return; | |
| 5043 | } | ||
| 5044 | |||
| 5045 | ✗ | if ( sdci[17] <= 0 ) | |
| 5046 | { | ||
| 5047 | ✗ | Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5048 | ✗ | return; | |
| 5049 | } | ||
| 5050 | |||
| 5051 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5052 | ✗ | if ( refbmp == NULL ) return; | |
| 5053 | ✗ | int32_t cmb = (sdci[4]/10000); | |
| 5054 | ✗ | if((unsigned)cmb >= MAXCOMBOS) | |
| 5055 | { | ||
| 5056 | ✗ | Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 5057 | ✗ | return; | |
| 5058 | } | ||
| 5059 | |||
| 5060 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5061 | |||
| 5062 | ✗ | int32_t x1=sdci[2]/10000; | |
| 5063 | ✗ | int32_t y1=sdci[3]/10000; | |
| 5064 | |||
| 5065 | ✗ | const newcombo & c = combobuf[cmb]; | |
| 5066 | ✗ | int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 5067 | ✗ | int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip; | |
| 5068 | ✗ | int32_t skiprows=c.skipanimy; | |
| 5069 | |||
| 5070 | ✗ | TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows); | |
| 5071 | } | ||
| 5072 | |||
| 5073 | |||
| 5074 | ✗ | void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5075 | { | ||
| 5076 | /* layer, x, y, tile, color opacity */ | ||
| 5077 | //sdci[17] Bitmap Pointer | ||
| 5078 | |||
| 5079 | ✗ | int32_t opacity = sdci[6]/10000; | |
| 5080 | ✗ | if ( sdci[17] <= 0 ) | |
| 5081 | { | ||
| 5082 | ✗ | Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5083 | ✗ | return; | |
| 5084 | } | ||
| 5085 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5086 | ✗ | if ( refbmp == NULL ) return; | |
| 5087 | |||
| 5088 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5089 | |||
| 5090 | ✗ | if(opacity < 128) | |
| 5091 | ✗ | overtiletranslucent16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0, opacity); | |
| 5092 | else | ||
| 5093 | ✗ | overtile16(refbmp, sdci[4]/10000, xoffset+(sdci[2]/10000), yoffset+(sdci[3]/10000), sdci[5]/10000, 0); | |
| 5094 | } | ||
| 5095 | |||
| 5096 | ✗ | void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5097 | { | ||
| 5098 | /* layer, x, y, tile, is8bit, mask */ | ||
| 5099 | //sdci[17] Bitmap Pointer | ||
| 5100 | ✗ | if ( sdci[17] <= 0 ) | |
| 5101 | { | ||
| 5102 | ✗ | Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5103 | ✗ | return; | |
| 5104 | } | ||
| 5105 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5106 | ✗ | if ( refbmp == NULL ) return; | |
| 5107 | |||
| 5108 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5109 | |||
| 5110 | ✗ | int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000); | |
| 5111 | ✗ | bool is8bit = sdci[5]!=0, mask = sdci[6]!=0; | |
| 5112 | |||
| 5113 | ✗ | write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask); | |
| 5114 | } | ||
| 5115 | |||
| 5116 | ✗ | void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5117 | { | ||
| 5118 | /* layer, mask, color, ditherType, ditherArg */ | ||
| 5119 | //sdci[2] Mask Bitmap Pointer | ||
| 5120 | //sdci[3] Color | ||
| 5121 | //sdci[17] Bitmap Pointer | ||
| 5122 | ✗ | if ( sdci[17] <= 0 ) | |
| 5123 | { | ||
| 5124 | ✗ | Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5125 | ✗ | return; | |
| 5126 | } | ||
| 5127 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5128 | ✗ | if ( refbmp == NULL ) return; | |
| 5129 | ✗ | if ( sdci[2] <= 0 ) | |
| 5130 | { | ||
| 5131 | ✗ | Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]); | |
| 5132 | ✗ | return; | |
| 5133 | } | ||
| 5134 | ✗ | BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10); | |
| 5135 | ✗ | if ( mask == NULL ) return; | |
| 5136 | |||
| 5137 | ✗ | int32_t dType = sdci[4] / 10000L; | |
| 5138 | ✗ | if(dType < 0 || dType >= dithMax) | |
| 5139 | { | ||
| 5140 | ✗ | Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType); | |
| 5141 | ✗ | return; | |
| 5142 | } | ||
| 5143 | |||
| 5144 | ✗ | ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L); | |
| 5145 | } | ||
| 5146 | |||
| 5147 | ✗ | void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5148 | { | ||
| 5149 | /* layer, shift, startcol, endcol */ | ||
| 5150 | //sdci[2] NewCol | ||
| 5151 | //sdci[3] StartCol | ||
| 5152 | //sdci[4] EndCol | ||
| 5153 | //sdci[17] Bitmap Pointer | ||
| 5154 | ✗ | if ( sdci[17] <= 0 ) | |
| 5155 | { | ||
| 5156 | ✗ | Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5157 | ✗ | return; | |
| 5158 | } | ||
| 5159 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5160 | ✗ | if ( refbmp == NULL ) return; | |
| 5161 | ✗ | replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false); | |
| 5162 | } | ||
| 5163 | |||
| 5164 | ✗ | void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5165 | { | ||
| 5166 | /* layer, shift, startcol, endcol */ | ||
| 5167 | //sdci[2] ShiftAmount | ||
| 5168 | //sdci[3] StartCol | ||
| 5169 | //sdci[4] EndCol | ||
| 5170 | //sdci[17] Bitmap Pointer | ||
| 5171 | ✗ | if ( sdci[17] <= 0 ) | |
| 5172 | { | ||
| 5173 | ✗ | Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5174 | ✗ | return; | |
| 5175 | } | ||
| 5176 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5177 | ✗ | if ( refbmp == NULL ) return; | |
| 5178 | ✗ | replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true); | |
| 5179 | } | ||
| 5180 | |||
| 5181 | ✗ | void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5182 | { | ||
| 5183 | /* layer, mask, color */ | ||
| 5184 | //sdci[2] Mask Bitmap Pointer | ||
| 5185 | //sdci[3] Color | ||
| 5186 | //sdci[4] start mask color | ||
| 5187 | //sdci[5] end mask color | ||
| 5188 | //sdci[17] Bitmap Pointer | ||
| 5189 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5190 | ✗ | if ( refbmp == NULL ) | |
| 5191 | { | ||
| 5192 | ✗ | Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5193 | ✗ | return; | |
| 5194 | } | ||
| 5195 | ✗ | BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10); | |
| 5196 | ✗ | if ( mask == NULL ) | |
| 5197 | { | ||
| 5198 | ✗ | Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]); | |
| 5199 | ✗ | return; | |
| 5200 | } | ||
| 5201 | ✗ | auto fillcol = sdci[3]/10000L; | |
| 5202 | ✗ | if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw | |
| 5203 | ✗ | auto startcol = vbound(sdci[4]/10000L,0x00,0xFF); | |
| 5204 | ✗ | auto endcol = vbound(sdci[5]/10000L,0x00,0xFF); | |
| 5205 | ✗ | mask_colorfill(refbmp, mask, fillcol, startcol, endcol); | |
| 5206 | } | ||
| 5207 | |||
| 5208 | ✗ | void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5209 | { | ||
| 5210 | /* layer, mask, color */ | ||
| 5211 | //sdci[2] Mask Bitmap Pointer | ||
| 5212 | //sdci[3] Pattern Bitmap | ||
| 5213 | //sdci[4] bool 'pattern repeats' | ||
| 5214 | //sdci[5] start mask color | ||
| 5215 | //sdci[6] end mask color | ||
| 5216 | //sdci[17] Bitmap Pointer | ||
| 5217 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5218 | ✗ | if ( refbmp == NULL ) | |
| 5219 | { | ||
| 5220 | ✗ | Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5221 | ✗ | return; | |
| 5222 | } | ||
| 5223 | ✗ | BITMAP *mask = FFCore.GetScriptBitmap(sdci[2]-10); | |
| 5224 | ✗ | if ( mask == NULL ) | |
| 5225 | { | ||
| 5226 | ✗ | Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]); | |
| 5227 | ✗ | return; | |
| 5228 | } | ||
| 5229 | ✗ | BITMAP *pattern = FFCore.GetScriptBitmap(sdci[3]-10); | |
| 5230 | ✗ | if ( pattern == NULL ) | |
| 5231 | { | ||
| 5232 | ✗ | Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]); | |
| 5233 | ✗ | return; | |
| 5234 | } | ||
| 5235 | ✗ | bool repeats = sdci[4]!=0; | |
| 5236 | ✗ | auto startcol = vbound(sdci[5]/10000L,0x00,0xFF); | |
| 5237 | ✗ | auto endcol = vbound(sdci[6]/10000L,0x00,0xFF); | |
| 5238 | ✗ | mask_blit(refbmp, mask, pattern, repeats, startcol, endcol); | |
| 5239 | } | ||
| 5240 | |||
| 5241 | ✗ | void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5242 | { | ||
| 5243 | /* layer, x, y, tile, color opacity */ | ||
| 5244 | //sdci[17] Bitmap Pointer | ||
| 5245 | ✗ | int32_t opacity = sdci[6] / 10000; | |
| 5246 | ✗ | int32_t x1 = sdci[2] / 10000; | |
| 5247 | ✗ | int32_t y1 = sdci[3] / 10000; | |
| 5248 | ✗ | int32_t index = sdci[4]/10000; | |
| 5249 | ✗ | if ( sdci[17] <= 0 ) | |
| 5250 | { | ||
| 5251 | ✗ | Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5252 | ✗ | return; | |
| 5253 | } | ||
| 5254 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5255 | ✗ | if ( refbmp == NULL ) return; | |
| 5256 | ✗ | int32_t cmb = (sdci[4]/10000); | |
| 5257 | ✗ | if((unsigned)cmb >= MAXCOMBOS) | |
| 5258 | { | ||
| 5259 | ✗ | Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb); | |
| 5260 | ✗ | return; | |
| 5261 | } | ||
| 5262 | |||
| 5263 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5264 | |||
| 5265 | //if( index >= MAXCOMBOS ) return; //bleh. | ||
| 5266 | /* | ||
| 5267 | const newcombo & c = combobuf[index]; | ||
| 5268 | |||
| 5269 | if(opacity < 128) | ||
| 5270 | overtiletranslucent16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip, opacity); | ||
| 5271 | else | ||
| 5272 | overtile16(refbmp, combo_tile(c, x1, y1), xoffset+x1, yoffset+y1, sdci[5]/10000, (int32_t)c.flip); | ||
| 5273 | */ | ||
| 5274 | |||
| 5275 | ✗ | if(opacity < 128) | |
| 5276 | { | ||
| 5277 | //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity) | ||
| 5278 | ✗ | overcomboblocktranslucent(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1, 128); | |
| 5279 | |||
| 5280 | } | ||
| 5281 | else | ||
| 5282 | { | ||
| 5283 | //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h) | ||
| 5284 | ✗ | overcomboblock(refbmp, xoffset+x1, yoffset+y1, cmb, sdci[5]/10000, 1, 1); | |
| 5285 | } | ||
| 5286 | } | ||
| 5287 | |||
| 5288 | |||
| 5289 | |||
| 5290 | ✗ | void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5291 | { | ||
| 5292 | //sdci[17] Bitmap Pointer | ||
| 5293 | ✗ | if ( sdci[17] <= 0 ) | |
| 5294 | { | ||
| 5295 | ✗ | Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5296 | ✗ | return; | |
| 5297 | } | ||
| 5298 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5299 | ✗ | if ( refbmp == NULL ) return; | |
| 5300 | |||
| 5301 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5302 | |||
| 5303 | //broken 2.50.2 and earlier drawcharacter() | ||
| 5304 | ✗ | if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) ) | |
| 5305 | { | ||
| 5306 | //sdci[1]=layer | ||
| 5307 | //sdci[2]=x | ||
| 5308 | //sdci[3]=y | ||
| 5309 | //sdci[4]=font | ||
| 5310 | //sdci[5]=color | ||
| 5311 | //sdci[6]=bg color | ||
| 5312 | //sdci[7]=strech x (width) | ||
| 5313 | //sdci[8]=stretch y (height) | ||
| 5314 | //sdci[9]=char | ||
| 5315 | //sdci[10]=opacity | ||
| 5316 | //sdci[17] Bitmap Pointer | ||
| 5317 | |||
| 5318 | ✗ | int32_t x=sdci[2]/10000; | |
| 5319 | ✗ | int32_t y=sdci[3]/10000; | |
| 5320 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 5321 | ✗ | int32_t color=sdci[5]/10000; | |
| 5322 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5323 | ✗ | int32_t w=sdci[7]/10000; | |
| 5324 | ✗ | int32_t h=sdci[8]/10000; | |
| 5325 | ✗ | char glyph=char(sdci[9]/10000); | |
| 5326 | ✗ | int32_t opacity=sdci[10]/10000; | |
| 5327 | |||
| 5328 | //safe check | ||
| 5329 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5330 | |||
| 5331 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 5332 | |||
| 5333 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 5334 | |||
| 5335 | //undone | ||
| 5336 | ✗ | if(w>0&&h>0)//stretch the character | |
| 5337 | { | ||
| 5338 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 5339 | |||
| 5340 | ✗ | if(opacity < 128) | |
| 5341 | { | ||
| 5342 | ✗ | if(w>128||h>128) | |
| 5343 | { | ||
| 5344 | ✗ | clear_bitmap(prim_bmp); | |
| 5345 | |||
| 5346 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5347 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 5348 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset); | |
| 5349 | } | ||
| 5350 | else //this is faster | ||
| 5351 | { | ||
| 5352 | ✗ | BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h); | |
| 5353 | |||
| 5354 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5355 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 5356 | ✗ | draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset); | |
| 5357 | |||
| 5358 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbmp2); | |
| 5359 | } | ||
| 5360 | } | ||
| 5361 | else // no opacity | ||
| 5362 | { | ||
| 5363 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5364 | ✗ | stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 5365 | } | ||
| 5366 | |||
| 5367 | } | ||
| 5368 | else //no stretch | ||
| 5369 | { | ||
| 5370 | ✗ | if(opacity < 128) | |
| 5371 | { | ||
| 5372 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 5373 | ✗ | clear_bitmap(pbmp); | |
| 5374 | |||
| 5375 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5376 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5377 | |||
| 5378 | ✗ | destroy_bitmap(pbmp); | |
| 5379 | } | ||
| 5380 | else // no opacity | ||
| 5381 | { | ||
| 5382 | ✗ | textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph); | |
| 5383 | } | ||
| 5384 | } | ||
| 5385 | } | ||
| 5386 | |||
| 5387 | else //2.53.0 fixed version and later. | ||
| 5388 | { | ||
| 5389 | |||
| 5390 | //sdci[1]=layer | ||
| 5391 | //sdci[2]=x | ||
| 5392 | //sdci[3]=y | ||
| 5393 | //sdci[4]=font | ||
| 5394 | //sdci[5]=color | ||
| 5395 | //sdci[6]=bg color | ||
| 5396 | //sdci[7]=strech x (width) | ||
| 5397 | //sdci[8]=stretch y (height) | ||
| 5398 | //sdci[9]=char | ||
| 5399 | //sdci[10]=opacity | ||
| 5400 | |||
| 5401 | ✗ | int32_t x=sdci[2]/10000; | |
| 5402 | ✗ | int32_t y=sdci[3]/10000; | |
| 5403 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 5404 | ✗ | int32_t color=sdci[5]/10000; | |
| 5405 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5406 | ✗ | int32_t w=sdci[7]/10000; | |
| 5407 | ✗ | int32_t h=sdci[8]/10000; | |
| 5408 | ✗ | char glyph=char(sdci[9]/10000); | |
| 5409 | ✗ | int32_t opacity=sdci[10]/10000; | |
| 5410 | |||
| 5411 | //safe check | ||
| 5412 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5413 | |||
| 5414 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 5415 | |||
| 5416 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 5417 | |||
| 5418 | //undone | ||
| 5419 | ✗ | if(w>0&&h>0)//stretch the character | |
| 5420 | { | ||
| 5421 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 5422 | |||
| 5423 | ✗ | if(opacity < 128) | |
| 5424 | { | ||
| 5425 | ✗ | if(w>128||h>128) | |
| 5426 | { | ||
| 5427 | ✗ | clear_bitmap(prim_bmp); | |
| 5428 | |||
| 5429 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5430 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 5431 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset); | |
| 5432 | } | ||
| 5433 | else //this is faster | ||
| 5434 | { | ||
| 5435 | ✗ | BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h); | |
| 5436 | |||
| 5437 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5438 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 5439 | ✗ | draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset); | |
| 5440 | |||
| 5441 | ✗ | script_drawing_commands.ReleaseSubBitmap(pbmp2); | |
| 5442 | } | ||
| 5443 | } | ||
| 5444 | else // no opacity | ||
| 5445 | { | ||
| 5446 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5447 | ✗ | stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 5448 | } | ||
| 5449 | |||
| 5450 | } | ||
| 5451 | else //no stretch | ||
| 5452 | { | ||
| 5453 | ✗ | if(opacity < 128) | |
| 5454 | { | ||
| 5455 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 5456 | ✗ | clear_bitmap(pbmp); | |
| 5457 | |||
| 5458 | ✗ | textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph); | |
| 5459 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5460 | |||
| 5461 | ✗ | destroy_bitmap(pbmp); | |
| 5462 | } | ||
| 5463 | else // no opacity | ||
| 5464 | { | ||
| 5465 | ✗ | textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph); | |
| 5466 | } | ||
| 5467 | } | ||
| 5468 | |||
| 5469 | } | ||
| 5470 | |||
| 5471 | } | ||
| 5472 | |||
| 5473 | |||
| 5474 | ✗ | void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5475 | { | ||
| 5476 | ✗ | if ( sdci[17] <= 0 ) | |
| 5477 | { | ||
| 5478 | ✗ | Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5479 | ✗ | return; | |
| 5480 | } | ||
| 5481 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5482 | ✗ | if ( refbmp == NULL ) return; | |
| 5483 | |||
| 5484 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5485 | |||
| 5486 | //broken 2.50.2 and earlier drawinteger() | ||
| 5487 | ✗ | if ( get_bit(quest_rules, qr_BROKENCHARINTDRAWING) ) | |
| 5488 | { | ||
| 5489 | //sdci[1]=layer | ||
| 5490 | //sdci[2]=x | ||
| 5491 | //sdci[3]=y | ||
| 5492 | //sdci[4]=font | ||
| 5493 | //sdci[5]=color | ||
| 5494 | //sdci[6]=bg color | ||
| 5495 | //sdci[7]=strech x (width) | ||
| 5496 | //sdci[8]=stretch y (height) | ||
| 5497 | //sdci[9]=integer | ||
| 5498 | //sdci[10]=num decimal places | ||
| 5499 | //sdci[11]=opacity | ||
| 5500 | //sdci[17] Bitmap Pointer | ||
| 5501 | |||
| 5502 | ✗ | int32_t x=sdci[2]/10000; | |
| 5503 | ✗ | int32_t y=sdci[3]/10000; | |
| 5504 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 5505 | ✗ | int32_t color=sdci[5]/10000; | |
| 5506 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5507 | ✗ | int32_t w=sdci[7]/10000; | |
| 5508 | ✗ | int32_t h=sdci[8]/10000; | |
| 5509 | //float number=static_cast<float>(sdci[9])/10000.0f; | ||
| 5510 | ✗ | int32_t decplace=sdci[10]/10000; | |
| 5511 | ✗ | int32_t opacity=sdci[11]/10000; | |
| 5512 | |||
| 5513 | //safe check | ||
| 5514 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5515 | |||
| 5516 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 5517 | |||
| 5518 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 5519 | |||
| 5520 | char numbuf[15]; | ||
| 5521 | |||
| 5522 | ✗ | switch(decplace) | |
| 5523 | { | ||
| 5524 | default: | ||
| 5525 | case 0: | ||
| 5526 | ✗ | sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was | |
| 5527 | ✗ | break; //reducing the value by -1, so 8.000 printed as '7'. -Z | |
| 5528 | |||
| 5529 | case 1: | ||
| 5530 | //sprintf(numbuf,"%.01f",number); | ||
| 5531 | ✗ | sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower? | |
| 5532 | ✗ | break; | |
| 5533 | |||
| 5534 | case 2: | ||
| 5535 | //sprintf(numbuf,"%.02f",number); | ||
| 5536 | ✗ | sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5537 | ✗ | break; | |
| 5538 | |||
| 5539 | case 3: | ||
| 5540 | //sprintf(numbuf,"%.03f",number); | ||
| 5541 | ✗ | sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5542 | ✗ | break; | |
| 5543 | |||
| 5544 | case 4: | ||
| 5545 | //sprintf(numbuf,"%.04f",number); | ||
| 5546 | ✗ | sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5547 | ✗ | break; | |
| 5548 | } | ||
| 5549 | |||
| 5550 | ✗ | if(w>0&&h>0)//stretch | |
| 5551 | { | ||
| 5552 | ✗ | BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1); | |
| 5553 | |||
| 5554 | ✗ | if(opacity < 128) | |
| 5555 | { | ||
| 5556 | ✗ | if(w>128||h>128) | |
| 5557 | { | ||
| 5558 | ✗ | clear_bitmap(prim_bmp); | |
| 5559 | |||
| 5560 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5561 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 5562 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset); | |
| 5563 | } | ||
| 5564 | else | ||
| 5565 | { | ||
| 5566 | ✗ | BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h); | |
| 5567 | ✗ | clear_bitmap(pbmp2); | |
| 5568 | |||
| 5569 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5570 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 5571 | ✗ | draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset); | |
| 5572 | |||
| 5573 | ✗ | destroy_bitmap(pbmp2); | |
| 5574 | } | ||
| 5575 | } | ||
| 5576 | else // no opacity | ||
| 5577 | { | ||
| 5578 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5579 | ✗ | stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 5580 | } | ||
| 5581 | |||
| 5582 | } | ||
| 5583 | else //no stretch | ||
| 5584 | { | ||
| 5585 | ✗ | if(opacity < 128) | |
| 5586 | { | ||
| 5587 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16); | |
| 5588 | ✗ | clear_bitmap(pbmp); | |
| 5589 | |||
| 5590 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5591 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5592 | |||
| 5593 | ✗ | destroy_bitmap(pbmp); | |
| 5594 | } | ||
| 5595 | else // no opacity | ||
| 5596 | { | ||
| 5597 | ✗ | textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color); | |
| 5598 | } | ||
| 5599 | } | ||
| 5600 | |||
| 5601 | } | ||
| 5602 | |||
| 5603 | else //2.53.0 fixed version and later. | ||
| 5604 | { | ||
| 5605 | //sdci[1]=layer | ||
| 5606 | //sdci[2]=x | ||
| 5607 | //sdci[3]=y | ||
| 5608 | //sdci[4]=font | ||
| 5609 | //sdci[5]=color | ||
| 5610 | //sdci[6]=bg color | ||
| 5611 | //sdci[7]=strech x (width) | ||
| 5612 | //sdci[8]=stretch y (height) | ||
| 5613 | //sdci[9]=integer | ||
| 5614 | //sdci[10]=num decimal places | ||
| 5615 | //sdci[11]=opacity | ||
| 5616 | |||
| 5617 | ✗ | int32_t x=sdci[2]/10000; | |
| 5618 | ✗ | int32_t y=sdci[3]/10000; | |
| 5619 | ✗ | int32_t font_index=sdci[4]/10000; | |
| 5620 | ✗ | int32_t color=sdci[5]/10000; | |
| 5621 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5622 | ✗ | int32_t w=sdci[7]/10000; | |
| 5623 | ✗ | int32_t h=sdci[8]/10000; | |
| 5624 | //float number=static_cast<float>(sdci[9])/10000.0f; | ||
| 5625 | //int32_t numberint = sdci[9]/10000; | ||
| 5626 | ✗ | int32_t decplace=sdci[10]/10000; | |
| 5627 | ✗ | int32_t opacity=sdci[11]/10000; | |
| 5628 | |||
| 5629 | //safe check | ||
| 5630 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5631 | |||
| 5632 | ✗ | if(w>512) w=512; //w=vbound(w,0,512); | |
| 5633 | |||
| 5634 | ✗ | if(h>512) h=512; //h=vbound(h,0,512); | |
| 5635 | |||
| 5636 | char numbuf[15]; | ||
| 5637 | |||
| 5638 | ✗ | switch(decplace) | |
| 5639 | { | ||
| 5640 | default: | ||
| 5641 | case 0: | ||
| 5642 | ✗ | sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was | |
| 5643 | ✗ | break; //reducing the value by -1, so 8.000 printed as '7'. -Z | |
| 5644 | |||
| 5645 | case 1: | ||
| 5646 | //sprintf(numbuf,"%.01f",number); | ||
| 5647 | ✗ | sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower? | |
| 5648 | ✗ | break; | |
| 5649 | |||
| 5650 | case 2: | ||
| 5651 | //sprintf(numbuf,"%.02f",number); | ||
| 5652 | ✗ | sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5653 | ✗ | break; | |
| 5654 | |||
| 5655 | case 3: | ||
| 5656 | //sprintf(numbuf,"%.03f",number); | ||
| 5657 | ✗ | sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5658 | ✗ | break; | |
| 5659 | |||
| 5660 | case 4: | ||
| 5661 | //sprintf(numbuf,"%.04f",number); | ||
| 5662 | ✗ | sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f)); | |
| 5663 | ✗ | break; | |
| 5664 | } | ||
| 5665 | |||
| 5666 | //FONT* font=get_zc_font(sdci[4]/10000); | ||
| 5667 | |||
| 5668 | ✗ | if(w>0&&h>0)//stretch | |
| 5669 | { | ||
| 5670 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index))); | |
| 5671 | ✗ | clear_bitmap(pbmp); | |
| 5672 | //script_drawing_commands.GetSmallTextureBitmap(1,1); | ||
| 5673 | |||
| 5674 | ✗ | if(opacity < 128) | |
| 5675 | { | ||
| 5676 | ✗ | if(w>128||h>128) | |
| 5677 | { | ||
| 5678 | ✗ | clear_bitmap(prim_bmp); | |
| 5679 | |||
| 5680 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5681 | ✗ | stretch_sprite(prim_bmp, pbmp, 0, 0, w, h); | |
| 5682 | ✗ | draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset); | |
| 5683 | } | ||
| 5684 | else | ||
| 5685 | { | ||
| 5686 | ✗ | BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h); | |
| 5687 | ✗ | clear_bitmap(pbmp2); | |
| 5688 | |||
| 5689 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5690 | ✗ | stretch_sprite(pbmp2, pbmp, 0, 0, w, h); | |
| 5691 | ✗ | draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset); | |
| 5692 | |||
| 5693 | ✗ | destroy_bitmap(pbmp2); | |
| 5694 | } | ||
| 5695 | } | ||
| 5696 | else // no opacity | ||
| 5697 | { | ||
| 5698 | ✗ | textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color); | |
| 5699 | ✗ | stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h); | |
| 5700 | } | ||
| 5701 | |||
| 5702 | } | ||
| 5703 | else //no stretch | ||
| 5704 | { | ||
| 5705 | ✗ | if(opacity < 128) | |
| 5706 | { | ||
| 5707 | ✗ | FONT* font = get_zc_font(font_index); | |
| 5708 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font)); | |
| 5709 | ✗ | clear_bitmap(pbmp); | |
| 5710 | |||
| 5711 | ✗ | textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color); | |
| 5712 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5713 | |||
| 5714 | ✗ | destroy_bitmap(pbmp); | |
| 5715 | } | ||
| 5716 | else // no opacity | ||
| 5717 | { | ||
| 5718 | ✗ | textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color); | |
| 5719 | } | ||
| 5720 | } | ||
| 5721 | } | ||
| 5722 | } | ||
| 5723 | |||
| 5724 | |||
| 5725 | ✗ | void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5726 | { | ||
| 5727 | //sdci[1]=layer | ||
| 5728 | //sdci[2]=x | ||
| 5729 | //sdci[3]=y | ||
| 5730 | //sdci[4]=font | ||
| 5731 | //sdci[5]=color | ||
| 5732 | //sdci[6]=bg color | ||
| 5733 | //sdci[7]=format_option | ||
| 5734 | //sdci[8]=string | ||
| 5735 | //sdci[9]=opacity | ||
| 5736 | //sdci[17] Bitmap Pointer | ||
| 5737 | ✗ | if ( sdci[17] <= 0 ) | |
| 5738 | { | ||
| 5739 | ✗ | Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5740 | ✗ | return; | |
| 5741 | } | ||
| 5742 | |||
| 5743 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5744 | ✗ | if ( refbmp == NULL ) return; | |
| 5745 | |||
| 5746 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5747 | |||
| 5748 | ✗ | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 5749 | |||
| 5750 | ✗ | if(!str) | |
| 5751 | { | ||
| 5752 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 5753 | ✗ | return; | |
| 5754 | } | ||
| 5755 | |||
| 5756 | ✗ | int32_t x=sdci[2]/10000; | |
| 5757 | ✗ | int32_t y=sdci[3]/10000; | |
| 5758 | ✗ | FONT* font=get_zc_font(sdci[4]/10000); | |
| 5759 | ✗ | int32_t color=sdci[5]/10000; | |
| 5760 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5761 | ✗ | int32_t format_type=sdci[7]/10000; | |
| 5762 | ✗ | int32_t opacity=sdci[9]/10000; | |
| 5763 | //sdci[8] not needed :) | ||
| 5764 | |||
| 5765 | //safe check | ||
| 5766 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5767 | |||
| 5768 | ✗ | if(opacity < 128) | |
| 5769 | { | ||
| 5770 | ✗ | int32_t width=zc_min(text_length(font, str->c_str()), 512); | |
| 5771 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font)); | |
| 5772 | ✗ | clear_bitmap(pbmp); | |
| 5773 | ✗ | textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color); | |
| 5774 | ✗ | if(format_type == 2) // right-sided text | |
| 5775 | ✗ | x-=width; | |
| 5776 | ✗ | else if(format_type == 1) // centered text | |
| 5777 | ✗ | x-=width/2; | |
| 5778 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5779 | ✗ | destroy_bitmap(pbmp); | |
| 5780 | } | ||
| 5781 | else // no opacity | ||
| 5782 | { | ||
| 5783 | ✗ | if(format_type == 2) // right-sided text | |
| 5784 | { | ||
| 5785 | ✗ | textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 5786 | } | ||
| 5787 | ✗ | else if(format_type == 1) // centered text | |
| 5788 | { | ||
| 5789 | ✗ | textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 5790 | } | ||
| 5791 | else // standard left-sided text | ||
| 5792 | { | ||
| 5793 | ✗ | textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color); | |
| 5794 | } | ||
| 5795 | } | ||
| 5796 | } | ||
| 5797 | |||
| 5798 | ✗ | void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5799 | { | ||
| 5800 | //sdci[1]=layer | ||
| 5801 | //sdci[2]=x | ||
| 5802 | //sdci[3]=y | ||
| 5803 | //sdci[4]=font | ||
| 5804 | //sdci[5]=color | ||
| 5805 | //sdci[6]=bg color | ||
| 5806 | //sdci[7]=format_option | ||
| 5807 | //sdci[8]=string | ||
| 5808 | //sdci[9]=opacity | ||
| 5809 | //sdci[10]=shadowtype | ||
| 5810 | //sdci[11]=shadow_color | ||
| 5811 | //sdci[17] Bitmap Pointer | ||
| 5812 | ✗ | if ( sdci[17] <= 0 ) | |
| 5813 | { | ||
| 5814 | ✗ | Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5815 | ✗ | return; | |
| 5816 | } | ||
| 5817 | |||
| 5818 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 5819 | ✗ | if ( refbmp == NULL ) return; | |
| 5820 | |||
| 5821 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 5822 | |||
| 5823 | ✗ | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 5824 | |||
| 5825 | ✗ | if(!str) | |
| 5826 | { | ||
| 5827 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 5828 | ✗ | return; | |
| 5829 | } | ||
| 5830 | |||
| 5831 | ✗ | int32_t x=sdci[2]/10000; | |
| 5832 | ✗ | int32_t y=sdci[3]/10000; | |
| 5833 | ✗ | FONT* font=get_zc_font(sdci[4]/10000); | |
| 5834 | ✗ | int32_t color=sdci[5]/10000; | |
| 5835 | ✗ | int32_t bg_color=sdci[6]/10000; //-1 = transparent | |
| 5836 | ✗ | int32_t format_type=sdci[7]/10000; | |
| 5837 | ✗ | int32_t opacity=sdci[9]/10000; | |
| 5838 | ✗ | int32_t textstyle = sdci[10]/10000; | |
| 5839 | ✗ | int32_t shadow_color = sdci[11]/10000; | |
| 5840 | //sdci[8] not needed :) | ||
| 5841 | |||
| 5842 | //safe check | ||
| 5843 | ✗ | if(bg_color < -1) bg_color = -1; | |
| 5844 | |||
| 5845 | ✗ | if(opacity < 128) | |
| 5846 | { | ||
| 5847 | ✗ | int32_t width=zc_min(text_length(font, str->c_str()), 512); | |
| 5848 | ✗ | BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font)); | |
| 5849 | ✗ | clear_bitmap(pbmp); | |
| 5850 | ✗ | textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color); | |
| 5851 | ✗ | if(format_type == 2) // right-sided text | |
| 5852 | ✗ | x-=width; | |
| 5853 | ✗ | else if(format_type == 1) // centered text | |
| 5854 | ✗ | x-=width/2; | |
| 5855 | ✗ | draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset); | |
| 5856 | ✗ | destroy_bitmap(pbmp); | |
| 5857 | } | ||
| 5858 | else // no opacity | ||
| 5859 | { | ||
| 5860 | ✗ | textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color); | |
| 5861 | } | ||
| 5862 | } | ||
| 5863 | |||
| 5864 | ✗ | void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5865 | { | ||
| 5866 | //sdci[1]=layer | ||
| 5867 | //sdci[17] Bitmap Pointer | ||
| 5868 | //Z_scripterrlog("bitmap->Clear() pointer is: %d\n", sdci[17]); | ||
| 5869 | ✗ | if ( sdci[17] <= 0 ) | |
| 5870 | { | ||
| 5871 | ✗ | Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5872 | ✗ | return; | |
| 5873 | } | ||
| 5874 | ✗ | int32_t bitid = sdci[17] - 10; | |
| 5875 | ✗ | if ( scb.script_created_bitmaps[bitid].u_bmp ) | |
| 5876 | ✗ | clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp); | |
| 5877 | } | ||
| 5878 | |||
| 5879 | ✗ | void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5880 | { | ||
| 5881 | //sdci[1]=layer | ||
| 5882 | //sdci[2]=color | ||
| 5883 | //sdci[17] Bitmap Pointer | ||
| 5884 | ✗ | int32_t pal_color = sdci[2]/10000; | |
| 5885 | ✗ | if ( sdci[17] <= 0 ) | |
| 5886 | { | ||
| 5887 | ✗ | Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5888 | ✗ | return; | |
| 5889 | } | ||
| 5890 | ✗ | int32_t bitid = sdci[17] - 10; | |
| 5891 | ✗ | if ( scb.script_created_bitmaps[bitid].u_bmp ) | |
| 5892 | ✗ | clear_to_color(scb.script_created_bitmaps[bitid].u_bmp, pal_color); | |
| 5893 | } | ||
| 5894 | |||
| 5895 | |||
| 5896 | ✗ | void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5897 | { | ||
| 5898 | //sdci[1]=layer | ||
| 5899 | ✗ | int32_t h = sdci[3]/10000; | |
| 5900 | ✗ | int32_t w = sdci[2]/10000; | |
| 5901 | ✗ | if ( get_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS) ) | |
| 5902 | { | ||
| 5903 | //flip height and width | ||
| 5904 | ✗ | h = h ^ w; | |
| 5905 | ✗ | w = h ^ w; | |
| 5906 | ✗ | h = h ^ w; | |
| 5907 | } | ||
| 5908 | //sdci[17] Bitmap Pointer | ||
| 5909 | //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[17]); | ||
| 5910 | ✗ | if ( sdci[17] <= 0 ) | |
| 5911 | { | ||
| 5912 | ✗ | Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5913 | ✗ | return; | |
| 5914 | } | ||
| 5915 | ✗ | int32_t bitid = sdci[17] - 10; | |
| 5916 | ✗ | if ( scb.script_created_bitmaps[bitid].u_bmp ) | |
| 5917 | ✗ | destroy_bitmap(scb.script_created_bitmaps[bitid].u_bmp); | |
| 5918 | ✗ | scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,w,h); | |
| 5919 | |||
| 5920 | ✗ | scb.script_created_bitmaps[bitid].width = w; | |
| 5921 | ✗ | scb.script_created_bitmaps[bitid].height = h; | |
| 5922 | |||
| 5923 | |||
| 5924 | |||
| 5925 | } | ||
| 5926 | |||
| 5927 | ✗ | void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5928 | { | ||
| 5929 | //sdci[1]=layer | ||
| 5930 | //sdci[2]=filename | ||
| 5931 | //sdci[3]=y | ||
| 5932 | //sdci[4]=font | ||
| 5933 | //sdci[5]=color | ||
| 5934 | //sdci[6]=bg color | ||
| 5935 | //sdci[7]=format_option | ||
| 5936 | //sdci[8]=string | ||
| 5937 | //sdci[9]=opacity | ||
| 5938 | //sdci[17] Bitmap Pointer | ||
| 5939 | //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[17]); | ||
| 5940 | ✗ | if ( sdci[17] <= 0 ) | |
| 5941 | { | ||
| 5942 | ✗ | Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 5943 | ✗ | return; | |
| 5944 | } | ||
| 5945 | ✗ | int32_t bitid = sdci[17] - 10; | |
| 5946 | ✗ | scb.script_created_bitmaps[bitid].destroy(); | |
| 5947 | |||
| 5948 | ✗ | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 5949 | |||
| 5950 | //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte | ||
| 5951 | // std::strncpy(cptr, str->c_str(), str->size()); | ||
| 5952 | // Z_scripterrlog("The following should be the filename string:\n"); | ||
| 5953 | //Z_scripterrlog(" %s\n", cptr); | ||
| 5954 | |||
| 5955 | ✗ | if(!str) | |
| 5956 | { | ||
| 5957 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 5958 | ✗ | return; | |
| 5959 | } | ||
| 5960 | |||
| 5961 | // Z_scripterrlog("Trying to read filename %s\n", cptr); | ||
| 5962 | PALETTE tempPal; | ||
| 5963 | ✗ | get_palette(tempPal); | |
| 5964 | ✗ | if ( checkPath(str->c_str(), false) ) | |
| 5965 | { | ||
| 5966 | ✗ | scb.script_created_bitmaps[bitid].u_bmp = load_bitmap(str->c_str(), tempPal); | |
| 5967 | ✗ | scb.script_created_bitmaps[bitid].width = scb.script_created_bitmaps[bitid].u_bmp->w; | |
| 5968 | ✗ | scb.script_created_bitmaps[bitid].height = scb.script_created_bitmaps[bitid].u_bmp->h; | |
| 5969 | ✗ | if ( !scb.script_created_bitmaps[bitid].u_bmp ) | |
| 5970 | { | ||
| 5971 | ✗ | Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str()); | |
| 5972 | //scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176); | ||
| 5973 | //clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp); | ||
| 5974 | } | ||
| 5975 | else | ||
| 5976 | { | ||
| 5977 | ✗ | zprint("Read image file %s\n",str->c_str()); | |
| 5978 | } | ||
| 5979 | } | ||
| 5980 | else | ||
| 5981 | { | ||
| 5982 | ✗ | Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str()); | |
| 5983 | ✗ | scb.script_created_bitmaps[bitid].u_bmp = create_bitmap_ex(8,256,176); | |
| 5984 | ✗ | clear_bitmap(scb.script_created_bitmaps[bitid].u_bmp); | |
| 5985 | } | ||
| 5986 | } | ||
| 5987 | |||
| 5988 | |||
| 5989 | |||
| 5990 | ✗ | void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 5991 | { | ||
| 5992 | //sdci[1]=layer | ||
| 5993 | //sdci[2]=filename | ||
| 5994 | //sdci[3]=y | ||
| 5995 | //sdci[4]=font | ||
| 5996 | //sdci[5]=color | ||
| 5997 | //sdci[6]=bg color | ||
| 5998 | //sdci[7]=format_option | ||
| 5999 | //sdci[8]=string | ||
| 6000 | //sdci[9]=opacity | ||
| 6001 | //sdci[17] Bitmap Pointer | ||
| 6002 | //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[17]); | ||
| 6003 | |||
| 6004 | ✗ | if ( sdci[17] <= 0 ) | |
| 6005 | { | ||
| 6006 | ✗ | Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 6007 | ✗ | return; | |
| 6008 | } | ||
| 6009 | ✗ | int32_t bitid = sdci[17] - 10; | |
| 6010 | |||
| 6011 | ✗ | if ( !scb.script_created_bitmaps[bitid].u_bmp ) | |
| 6012 | { | ||
| 6013 | ✗ | Z_scripterrlog("Tried to write from an invalid bitmap pointer %d. Aborting. \n", sdci[17]); | |
| 6014 | ✗ | return; | |
| 6015 | } | ||
| 6016 | |||
| 6017 | ✗ | bool overwrite = (sdci[3] != 0); | |
| 6018 | ✗ | std::string* str = (std::string*)script_drawing_commands[i].GetPtr(); | |
| 6019 | |||
| 6020 | ✗ | if(!str) | |
| 6021 | { | ||
| 6022 | ✗ | al_trace("String pointer is null! Internal error. \n"); | |
| 6023 | ✗ | return; | |
| 6024 | } | ||
| 6025 | |||
| 6026 | //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte | ||
| 6027 | //std::strncpy(cptr, str->c_str(), str->size()); | ||
| 6028 | //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false"); | ||
| 6029 | //Z_scripterrlog("Trying to write filename %s\n", cptr); | ||
| 6030 | if | ||
| 6031 | ( | ||
| 6032 | ✗ | ( (FFCore.checkExtension(*str, "")) ) || | |
| 6033 | ✗ | ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp")) | |
| 6034 | ✗ | && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) ) | |
| 6035 | ) | ||
| 6036 | { | ||
| 6037 | ✗ | Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str()); | |
| 6038 | } | ||
| 6039 | ✗ | else if ( overwrite || (!checkPath(str->c_str(), false)) ) | |
| 6040 | { | ||
| 6041 | ✗ | if(create_path(str->c_str())) | |
| 6042 | { | ||
| 6043 | ✗ | save_bitmap(str->c_str(), scb.script_created_bitmaps[bitid].u_bmp, RAMpal); | |
| 6044 | ✗ | if(checkPath(str->c_str(), false)) | |
| 6045 | { | ||
| 6046 | ✗ | zprint("Wrote image file %s\n",str->c_str()); | |
| 6047 | } | ||
| 6048 | else | ||
| 6049 | { | ||
| 6050 | ✗ | Z_scripterrlog("Failed to create file '%s'\n",str->c_str()); | |
| 6051 | } | ||
| 6052 | } | ||
| 6053 | else | ||
| 6054 | { | ||
| 6055 | ✗ | Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str()); | |
| 6056 | } | ||
| 6057 | } | ||
| 6058 | ✗ | else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str()); | |
| 6059 | } | ||
| 6060 | |||
| 6061 | |||
| 6062 | ✗ | void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 6063 | { | ||
| 6064 | //sdci[1]=layer | ||
| 6065 | //sdci[2]=x1 | ||
| 6066 | //sdci[3]=y1 | ||
| 6067 | //sdci[4]=x2 | ||
| 6068 | //sdci[5]=y2 | ||
| 6069 | //sdci[6]=x3 | ||
| 6070 | //sdci[7]=y3 | ||
| 6071 | //sdci[8]=x4 | ||
| 6072 | //sdci[9]=y4 | ||
| 6073 | //sdci[10]=width | ||
| 6074 | //sdci[11]=height | ||
| 6075 | //sdci[12]=cset | ||
| 6076 | //sdci[13]=flip | ||
| 6077 | //sdci[14]=tile/combo | ||
| 6078 | //sdci[15]=polytype | ||
| 6079 | //sdci[16] = other bitmap as texture | ||
| 6080 | //sdci[17] Bitmap Pointer | ||
| 6081 | ✗ | Z_scripterrlog("bitmap quad pointer: %d\n", sdci[17]); | |
| 6082 | ✗ | if ( sdci[17] <= 0 ) | |
| 6083 | { | ||
| 6084 | ✗ | Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 6085 | ✗ | return; | |
| 6086 | } | ||
| 6087 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 6088 | |||
| 6089 | ✗ | if ( !refbmp ) return; | |
| 6090 | |||
| 6091 | ✗ | int32_t x1 = sdci[2]/10000; | |
| 6092 | ✗ | int32_t y1 = sdci[3]/10000; | |
| 6093 | ✗ | int32_t x2 = sdci[4]/10000; | |
| 6094 | ✗ | int32_t y2 = sdci[5]/10000; | |
| 6095 | ✗ | int32_t x3 = sdci[6]/10000; | |
| 6096 | ✗ | int32_t y3 = sdci[7]/10000; | |
| 6097 | ✗ | int32_t x4 = sdci[8]/10000; | |
| 6098 | ✗ | int32_t y4 = sdci[9]/10000; | |
| 6099 | ✗ | int32_t w = sdci[10]/10000; | |
| 6100 | ✗ | int32_t h = sdci[11]/10000; | |
| 6101 | ✗ | int32_t color = sdci[12]/10000; | |
| 6102 | ✗ | int32_t flip=(sdci[13]/10000)&3; | |
| 6103 | ✗ | int32_t tile = sdci[14]/10000; | |
| 6104 | ✗ | int32_t polytype = sdci[15]/10000; | |
| 6105 | ✗ | int32_t quad_render_source = sdci[16]-10; | |
| 6106 | //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source); | ||
| 6107 | |||
| 6108 | ✗ | bool tex_is_bitmap = ( sdci[16] != 0 ); | |
| 6109 | |||
| 6110 | ✗ | BITMAP *bmptexture=NULL; | |
| 6111 | ✗ | BITMAP *tex=NULL; | |
| 6112 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 6113 | |||
| 6114 | int32_t col[4]; | ||
| 6115 | ✗ | col[0]=col[1]=col[2]=col[3]=color; | |
| 6116 | ✗ | bool mustDestroyBmp = false; | |
| 6117 | |||
| 6118 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 6119 | |||
| 6120 | ✗ | if ( tex_is_bitmap ) | |
| 6121 | { | ||
| 6122 | ✗ | bmptexture = FFCore.GetScriptBitmap(quad_render_source); | |
| 6123 | ✗ | if ( !bmptexture ) | |
| 6124 | { | ||
| 6125 | ✗ | Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()"); | |
| 6126 | ✗ | tex_is_bitmap = 0; | |
| 6127 | } | ||
| 6128 | } | ||
| 6129 | |||
| 6130 | ✗ | if ( tex_is_bitmap ) | |
| 6131 | { | ||
| 6132 | |||
| 6133 | ✗ | if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 6134 | ✗ | if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 6135 | ✗ | if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w); | |
| 6136 | ✗ | if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h); | |
| 6137 | |||
| 6138 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 6139 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] }; | |
| 6140 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] }; | |
| 6141 | ✗ | V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] }; | |
| 6142 | |||
| 6143 | ✗ | quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4); | |
| 6144 | } | ||
| 6145 | else | ||
| 6146 | { | ||
| 6147 | ✗ | tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 6148 | ✗ | if(!tex) | |
| 6149 | { | ||
| 6150 | //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n"); | ||
| 6151 | ✗ | mustDestroyBmp = true; | |
| 6152 | ✗ | tex = create_bitmap_ex(8, w*16, h*16); | |
| 6153 | ✗ | clear_bitmap(tex); | |
| 6154 | } | ||
| 6155 | |||
| 6156 | ✗ | if(tile > 0) // TILE | |
| 6157 | { | ||
| 6158 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip); | |
| 6159 | } | ||
| 6160 | |||
| 6161 | ✗ | if ( tile < 0 ) // COMBO | |
| 6162 | { | ||
| 6163 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 6164 | ✗ | const int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 6165 | ✗ | flip = flip ^ c.flip; | |
| 6166 | |||
| 6167 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip); | |
| 6168 | } | ||
| 6169 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 6170 | { | ||
| 6171 | ✗ | Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 6172 | ✗ | return; //non power of two error | |
| 6173 | } | ||
| 6174 | //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n"); | ||
| 6175 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 6176 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] }; | |
| 6177 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] }; | |
| 6178 | ✗ | V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] }; | |
| 6179 | |||
| 6180 | ✗ | quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4); | |
| 6181 | |||
| 6182 | } | ||
| 6183 | |||
| 6184 | |||
| 6185 | |||
| 6186 | |||
| 6187 | //todo: finish palette shading | ||
| 6188 | /* | ||
| 6189 | POLYTYPE_FLAT | ||
| 6190 | POLYTYPE_GCOL | ||
| 6191 | POLYTYPE_GRGB | ||
| 6192 | POLYTYPE_ATEX | ||
| 6193 | POLYTYPE_PTEX | ||
| 6194 | POLYTYPE_ATEX_MASK | ||
| 6195 | POLYTYPE_PTEX_MASK | ||
| 6196 | POLYTYPE_ATEX_LIT | ||
| 6197 | POLYTYPE_PTEX_LIT | ||
| 6198 | POLYTYPE_ATEX_MASK_LIT | ||
| 6199 | POLYTYPE_PTEX_MASK_LIT | ||
| 6200 | POLYTYPE_ATEX_TRANS | ||
| 6201 | POLYTYPE_PTEX_TRANS | ||
| 6202 | POLYTYPE_ATEX_MASK_TRANS | ||
| 6203 | POLYTYPE_PTEX_MASK_TRANS | ||
| 6204 | */ | ||
| 6205 | |||
| 6206 | ✗ | if(mustDestroyBmp) | |
| 6207 | ✗ | destroy_bitmap(tex); | |
| 6208 | |||
| 6209 | } | ||
| 6210 | |||
| 6211 | |||
| 6212 | ✗ | void bmp_do_getpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 6213 | { | ||
| 6214 | //sdci[1]=layer | ||
| 6215 | //sdci[2]=x1 | ||
| 6216 | //sdci[3]=y1 | ||
| 6217 | |||
| 6218 | //sdci[17] Bitmap Pointer | ||
| 6219 | ✗ | if ( sdci[17] <= 0 ) | |
| 6220 | { | ||
| 6221 | ✗ | Z_scripterrlog("bitmap->GetPixel() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 6222 | ✗ | return; | |
| 6223 | } | ||
| 6224 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 6225 | ✗ | if ( refbmp == NULL ) return; | |
| 6226 | |||
| 6227 | |||
| 6228 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 6229 | |||
| 6230 | ✗ | int32_t x1 = sdci[2]/10000; | |
| 6231 | ✗ | int32_t y1 = (sdci[3]/10000)+yoffset; | |
| 6232 | ✗ | int32_t col = getpixel(scb.script_created_bitmaps[(sdci[17]-10)].u_bmp, x1, y1); | |
| 6233 | ✗ | Z_scripterrlog("bitmap->GetPixel col is %d\n",col); | |
| 6234 | ✗ | Z_scripterrlog("bitmap->GetPixel bitmap ptr is is %d\n",(sdci[17]-10)); | |
| 6235 | ✗ | FFCore.set_sarg1(col); | |
| 6236 | } | ||
| 6237 | |||
| 6238 | |||
| 6239 | |||
| 6240 | |||
| 6241 | ✗ | void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 6242 | { | ||
| 6243 | //sdci[1]=layer | ||
| 6244 | //sdci[2]=x1 | ||
| 6245 | //sdci[3]=y1 | ||
| 6246 | //sdci[4]=x2 | ||
| 6247 | //sdci[5]=y2 | ||
| 6248 | //sdci[6]=x3 | ||
| 6249 | //sdci[7]=y3 | ||
| 6250 | //sdci[8]=width | ||
| 6251 | //sdci[9]=height | ||
| 6252 | //sdci[10]=cset | ||
| 6253 | //sdci[11]=flip | ||
| 6254 | //sdci[12]=tile/combo | ||
| 6255 | //sdci[13]=polytype | ||
| 6256 | //sdci[17] Bitmap Pointer | ||
| 6257 | ✗ | if ( sdci[17] <= 0 ) | |
| 6258 | { | ||
| 6259 | ✗ | Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 6260 | ✗ | return; | |
| 6261 | } | ||
| 6262 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 6263 | ✗ | if ( refbmp == NULL ) return; | |
| 6264 | |||
| 6265 | |||
| 6266 | ✗ | int32_t render_source = sdci[14]-10; | |
| 6267 | //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source); | ||
| 6268 | |||
| 6269 | ✗ | bool tex_is_bitmap = ( sdci[14] != 0 ); | |
| 6270 | |||
| 6271 | ✗ | BITMAP *bmptexture=NULL; | |
| 6272 | ✗ | if ( tex_is_bitmap ) | |
| 6273 | { | ||
| 6274 | ✗ | bmptexture = FFCore.GetScriptBitmap(render_source); | |
| 6275 | ✗ | if ( !bmptexture ) | |
| 6276 | { | ||
| 6277 | ✗ | Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()"); | |
| 6278 | ✗ | tex_is_bitmap = 0; | |
| 6279 | } | ||
| 6280 | } | ||
| 6281 | |||
| 6282 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 6283 | |||
| 6284 | ✗ | int32_t x1 = sdci[2]/10000; | |
| 6285 | ✗ | int32_t y1 = sdci[3]/10000; | |
| 6286 | ✗ | int32_t x2 = sdci[4]/10000; | |
| 6287 | ✗ | int32_t y2 = sdci[5]/10000; | |
| 6288 | ✗ | int32_t x3 = sdci[6]/10000; | |
| 6289 | ✗ | int32_t y3 = sdci[7]/10000; | |
| 6290 | ✗ | int32_t w = sdci[8]/10000; | |
| 6291 | ✗ | int32_t h = sdci[9]/10000; | |
| 6292 | ✗ | int32_t color = sdci[10]/10000; | |
| 6293 | ✗ | int32_t flip=(sdci[11]/10000)&3; | |
| 6294 | ✗ | int32_t tile = sdci[12]/10000; | |
| 6295 | ✗ | int32_t polytype = sdci[13]/10000; | |
| 6296 | |||
| 6297 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 6298 | ✗ | int32_t utex_w = w; | |
| 6299 | ✗ | int32_t utex_h = h; | |
| 6300 | |||
| 6301 | |||
| 6302 | ✗ | int32_t tex_width = w*16; | |
| 6303 | ✗ | int32_t tex_height = h*16; | |
| 6304 | |||
| 6305 | ✗ | bool mustDestroyBmp = false; | |
| 6306 | ✗ | BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 6307 | |||
| 6308 | ✗ | if(!tex) | |
| 6309 | { | ||
| 6310 | ✗ | mustDestroyBmp = true; | |
| 6311 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 6312 | ✗ | clear_bitmap(tex); | |
| 6313 | } | ||
| 6314 | |||
| 6315 | int32_t col[3]; | ||
| 6316 | /* | ||
| 6317 | if( color < 0 ) | ||
| 6318 | { | ||
| 6319 | col[0]=draw_container.color_buffer[0]; | ||
| 6320 | col[1]=draw_container.color_buffer[1]; | ||
| 6321 | col[2]=draw_container.color_buffer[2]; | ||
| 6322 | } | ||
| 6323 | else */ | ||
| 6324 | { | ||
| 6325 | ✗ | col[0]=col[1]=col[2]=color; | |
| 6326 | } | ||
| 6327 | |||
| 6328 | ✗ | if(tile > 0) // TILE | |
| 6329 | { | ||
| 6330 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip); | |
| 6331 | } | ||
| 6332 | else // COMBO | ||
| 6333 | { | ||
| 6334 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 6335 | ✗ | const int32_t tiletodraw = combo_tile(c, x1, y1); | |
| 6336 | ✗ | flip = flip ^ c.flip; | |
| 6337 | |||
| 6338 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip); | |
| 6339 | } | ||
| 6340 | ✗ | if ( !tex_is_bitmap ) | |
| 6341 | { | ||
| 6342 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 6343 | { | ||
| 6344 | ✗ | Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 6345 | ✗ | return; //non power of two error | |
| 6346 | } | ||
| 6347 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 6348 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] }; | |
| 6349 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] }; | |
| 6350 | |||
| 6351 | |||
| 6352 | ✗ | triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3); | |
| 6353 | |||
| 6354 | } | ||
| 6355 | |||
| 6356 | else | ||
| 6357 | { | ||
| 6358 | ✗ | if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source); | |
| 6359 | ✗ | if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source); | |
| 6360 | ✗ | if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w); | |
| 6361 | ✗ | if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h); | |
| 6362 | |||
| 6363 | ✗ | V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] }; | |
| 6364 | ✗ | V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] }; | |
| 6365 | ✗ | V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] }; | |
| 6366 | |||
| 6367 | |||
| 6368 | ✗ | triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3); | |
| 6369 | |||
| 6370 | } | ||
| 6371 | |||
| 6372 | ✗ | if(mustDestroyBmp) | |
| 6373 | ✗ | destroy_bitmap(tex); | |
| 6374 | } | ||
| 6375 | |||
| 6376 | |||
| 6377 | ✗ | void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 6378 | { | ||
| 6379 | /* | ||
| 6380 | int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon, | ||
| 6381 | int32_t scale_x, int32_t scale_y){ | ||
| 6382 | |||
| 6383 | //sdci[1]=layer | ||
| 6384 | //sdci[2]=bitmap target | ||
| 6385 | // | ||
| 6386 | // -2 is the current Render Target | ||
| 6387 | // -1, this is the screen (framebuf). | ||
| 6388 | // 0: Render target 0 | ||
| 6389 | // 1: Render target 1 | ||
| 6390 | // 2: Render target 2 | ||
| 6391 | // 3: Render target 3 | ||
| 6392 | // 4: Render target 4 | ||
| 6393 | // 5: Render target 5 | ||
| 6394 | // 6: Render target 6 | ||
| 6395 | // Otherwise: The pointer to a bitmap. | ||
| 6396 | |||
| 6397 | //sdci[3]=sourcex | ||
| 6398 | //sdci[4]=sourcey | ||
| 6399 | //sdci[5]=sourcew | ||
| 6400 | //sdci[6]=sourceh | ||
| 6401 | |||
| 6402 | //sdci[7]=destw | ||
| 6403 | //sdci[8]=desth | ||
| 6404 | //sdci[9]=angle | ||
| 6405 | //scdi[10] = pivot cx | ||
| 6406 | //sdci[11] = pivot cy | ||
| 6407 | //sdci[12] = space Z | ||
| 6408 | //sdci[13] = horizon | ||
| 6409 | //scdi[14] = scale X | ||
| 6410 | //scdi[15] = scale Y | ||
| 6411 | //sdci[16] = masked? | ||
| 6412 | //sdci[17] Bitmap Pointer | ||
| 6413 | |||
| 6414 | |||
| 6415 | |||
| 6416 | // ZScript-side constant values: | ||
| 6417 | const int32_t BITDX_NORMAL = 0; | ||
| 6418 | const int32_t BITDX_TRANS = 1; //Translucent | ||
| 6419 | const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center. | ||
| 6420 | const int32_t BITDX_HFLIP = 4; //Horizontal Flip | ||
| 6421 | const int32_t BITDX_VFLIP = 8; //Vertical Flip. | ||
| 6422 | //Note: Some modes cannot be combined. if a combination is not supported, an error | ||
| 6423 | // detailing this will be shown in allegro.log. | ||
| 6424 | |||
| 6425 | //scdi[15] = litcolour | ||
| 6426 | //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | ||
| 6427 | //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 6428 | |||
| 6429 | //sdci[16]=mask | ||
| 6430 | |||
| 6431 | */ | ||
| 6432 | |||
| 6433 | |||
| 6434 | ✗ | int32_t bitmapIndex = sdci[2]; | |
| 6435 | ✗ | int32_t usr_bitmap_index = sdci[2]-10; | |
| 6436 | ✗ | byte using_user_bitmap = 0; | |
| 6437 | //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex); | ||
| 6438 | //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex); | ||
| 6439 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6440 | Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex); | ||
| 6441 | #endif | ||
| 6442 | ✗ | if ( bitmapIndex >= 10000 ) | |
| 6443 | { | ||
| 6444 | ✗ | bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8; | |
| 6445 | } | ||
| 6446 | ✗ | else if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 ) | |
| 6447 | { | ||
| 6448 | ✗ | bitmapIndex = usr_bitmap_index; | |
| 6449 | ✗ | using_user_bitmap = 1; | |
| 6450 | ✗ | Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index); | |
| 6451 | ✗ | yoffset = 0; | |
| 6452 | } | ||
| 6453 | |||
| 6454 | //int32_t sx = sdci[3]/10000; | ||
| 6455 | //int32_t sy = sdci[4]/10000; | ||
| 6456 | //int32_t sw = sdci[5]/10000; | ||
| 6457 | //Z_scripterrlog("sh is: %d\n",sdci[5]/10000); | ||
| 6458 | //int32_t sh = sdci[6]/10000; | ||
| 6459 | //Z_scripterrlog("sh is: %d\n",sdci[6]/10000); | ||
| 6460 | //int32_t dx = sdci[7]/10000; | ||
| 6461 | //int32_t dy = sdci[8]/10000; | ||
| 6462 | //int32_t dw = sdci[9]/10000; | ||
| 6463 | //int32_t dh = sdci[10]/10000; | ||
| 6464 | //float rot = sdci[11]/10000; | ||
| 6465 | //int32_t cx = sdci[12]/10000; | ||
| 6466 | //int32_t cy = sdci[13]/10000; | ||
| 6467 | //int32_t mode = sdci[14]/10000; | ||
| 6468 | //int32_t litcolour = sdci[15]/10000; | ||
| 6469 | |||
| 6470 | //rendering mode 7 args | ||
| 6471 | ✗ | double srcX = sdci[3]/10000.0; | |
| 6472 | ✗ | double srcY = sdci[4]/10000.0; | |
| 6473 | ✗ | double destX = sdci[5]/10000.0; | |
| 6474 | ✗ | double destY = sdci[6]/10000.0; | |
| 6475 | |||
| 6476 | |||
| 6477 | // int32_t srcW = sdci[5]/10000; | ||
| 6478 | // int32_t srcH = sdci[6]/10000; | ||
| 6479 | ✗ | double destW = sdci[7]/10000.0; | |
| 6480 | ✗ | double destH = sdci[8]/10000.0; | |
| 6481 | // int32_t angle = sdci[9]/10000; | ||
| 6482 | // int32_t cx = sdci[10]/10000; | ||
| 6483 | // int32_t cy = sdci[11]/10000; | ||
| 6484 | ✗ | double space_z = sdci[9]/10000.0; | |
| 6485 | ✗ | double horizon = sdci[10]/10000.0; | |
| 6486 | ✗ | double scale_x = sdci[11]/10000.0; | |
| 6487 | ✗ | double scale_y = sdci[12]/10000.0; | |
| 6488 | ✗ | byte masked = ( sdci[13] ) ? 1 : 0; | |
| 6489 | |||
| 6490 | |||
| 6491 | ✗ | int32_t ref = 0; | |
| 6492 | |||
| 6493 | //dx = 0 + xoffset; | ||
| 6494 | //dy = 0 + yoffset; | ||
| 6495 | |||
| 6496 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 6497 | //Do we need to also check the render target and do the same thing if the | ||
| 6498 | //dest == -2 and the render target is not RT_SCREEN? | ||
| 6499 | |||
| 6500 | ✗ | ref = sdci[17]; | |
| 6501 | //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref); | ||
| 6502 | ✗ | ref -=10; | |
| 6503 | //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref); | ||
| 6504 | |||
| 6505 | |||
| 6506 | ✗ | if ( ref <= 0 ) | |
| 6507 | { | ||
| 6508 | ✗ | Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref); | |
| 6509 | ✗ | return; | |
| 6510 | } | ||
| 6511 | ✗ | BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1. | |
| 6512 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6513 | Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]); | ||
| 6514 | #endif | ||
| 6515 | ✗ | if(!sourceBitmap) | |
| 6516 | { | ||
| 6517 | ✗ | Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref); | |
| 6518 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 6519 | ✗ | return; | |
| 6520 | } | ||
| 6521 | |||
| 6522 | ✗ | BITMAP *destBMP=NULL; | |
| 6523 | //zprint2("mode 7 bitmap index is: %d\n",bitmapIndex); | ||
| 6524 | ✗ | switch(bitmapIndex) | |
| 6525 | { | ||
| 6526 | case -2: | ||
| 6527 | { | ||
| 6528 | ✗ | int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); | |
| 6529 | //zprint2("current RT is: %d\n", curr_rt); | ||
| 6530 | ✗ | if ( curr_rt >= 0 && curr_rt < 7 ) | |
| 6531 | ✗ | destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget. | |
| 6532 | ✗ | else destBMP = bmp; //screen | |
| 6533 | ✗ | break; | |
| 6534 | } | ||
| 6535 | case -1: | ||
| 6536 | ✗ | destBMP = bmp; //this is framebuf, by default | |
| 6537 | ✗ | break; | |
| 6538 | //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex); | ||
| 6539 | //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 6540 | //destBMP = framebuf; //Drawing to the screen. | ||
| 6541 | //break; | ||
| 6542 | |||
| 6543 | //1 through 6 are the old system bitmaps (Render Targets) | ||
| 6544 | case 0: | ||
| 6545 | case 1: | ||
| 6546 | case 2: | ||
| 6547 | case 3: | ||
| 6548 | case 4: | ||
| 6549 | case 5: | ||
| 6550 | case 6: | ||
| 6551 | { | ||
| 6552 | //This gets a render target. | ||
| 6553 | //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break; | ||
| 6554 | |||
| 6555 | ✗ | destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex); | |
| 6556 | //sdci[18] = bitmapIndex; | ||
| 6557 | ✗ | break; | |
| 6558 | } | ||
| 6559 | //Otherwise, we are using a user-created bitmap, so, get that pointer insted. | ||
| 6560 | default: | ||
| 6561 | { | ||
| 6562 | ✗ | destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp; | |
| 6563 | //sdci[18] = usr_bitmap_index; | ||
| 6564 | ✗ | if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp ) | |
| 6565 | { | ||
| 6566 | ✗ | Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n"); | |
| 6567 | ✗ | break; | |
| 6568 | } | ||
| 6569 | } | ||
| 6570 | //FFCore.get_user_bitmap(bitmapIndex); break; | ||
| 6571 | } | ||
| 6572 | |||
| 6573 | |||
| 6574 | |||
| 6575 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6576 | Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex); | ||
| 6577 | #endif | ||
| 6578 | |||
| 6579 | |||
| 6580 | ✗ | if (!destBMP) | |
| 6581 | { | ||
| 6582 | ✗ | Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex); | |
| 6583 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 6584 | ✗ | return; | |
| 6585 | } | ||
| 6586 | |||
| 6587 | //bugfix | ||
| 6588 | //sx = vbound(sx, 0, sourceBitmap->w); | ||
| 6589 | /* //These vars are named wrongly for this function -V | ||
| 6590 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6591 | Z_scripterrlog("Blit %s is: %d\n", "sx", sx); | ||
| 6592 | Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w); | ||
| 6593 | #endif | ||
| 6594 | //sy = vbound(sy, 0, sourceBitmap->h); | ||
| 6595 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6596 | Z_scripterrlog("Blit %s is: %d\n", "sy", sy); | ||
| 6597 | Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h); | ||
| 6598 | #endif | ||
| 6599 | //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well | ||
| 6600 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6601 | Z_scripterrlog("Blit %s is: %d\n", "sw", sw); | ||
| 6602 | #endif | ||
| 6603 | //sh = vbound(sh, 0, sourceBitmap->h - sy); | ||
| 6604 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6605 | Z_scripterrlog("Blit %s is: %d\n", "sh", sh); | ||
| 6606 | |||
| 6607 | Z_scripterrlog("Blit %s is: %d\n", "dh", dh); | ||
| 6608 | Z_scripterrlog("Blit %s is: %d\n", "dw", dw); | ||
| 6609 | #endif | ||
| 6610 | //bool stretched = (sw != dw || sh != dh); | ||
| 6611 | //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h); | ||
| 6612 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6613 | Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false"); | ||
| 6614 | #endif | ||
| 6615 | */ | ||
| 6616 | //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 6617 | |||
| 6618 | |||
| 6619 | |||
| 6620 | |||
| 6621 | |||
| 6622 | ✗ | BITMAP* subBmp = 0; | |
| 6623 | |||
| 6624 | /* IDR what this was. -Z ( 17th April, 2019 ) | ||
| 6625 | if ( bitmapIndex == -1 ) { | ||
| 6626 | blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh); | ||
| 6627 | } | ||
| 6628 | */ | ||
| 6629 | |||
| 6630 | //if(rot != 0 || mode != 0) | ||
| 6631 | //{ | ||
| 6632 | // subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh); | ||
| 6633 | // clear_bitmap(subBmp); | ||
| 6634 | |||
| 6635 | // if(!subBmp) | ||
| 6636 | // { | ||
| 6637 | // Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation"); | ||
| 6638 | // return; | ||
| 6639 | // } | ||
| 6640 | //} | ||
| 6641 | |||
| 6642 | |||
| 6643 | //dx = dx + xoffset; //don't do this here! | ||
| 6644 | //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 ) | ||
| 6645 | //All of these are a factor of 10000 as fix. | ||
| 6646 | ✗ | int32_t screen_x = 0; int32_t screen_y = 0; | |
| 6647 | |||
| 6648 | ✗ | double distance = 0; double horizontal_scale = 0; | |
| 6649 | |||
| 6650 | ✗ | int32_t screen_y_horizon = 0; | |
| 6651 | |||
| 6652 | ✗ | double line_dx = 0; double line_dy = 0; | |
| 6653 | |||
| 6654 | ✗ | int32_t space_x = 0; int32_t space_y = 0; | |
| 6655 | |||
| 6656 | ✗ | for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000 | |
| 6657 | { | ||
| 6658 | //Calculate the distance of each line from the camera point | ||
| 6659 | ✗ | screen_y_horizon = screen_y + horizon; | |
| 6660 | |||
| 6661 | ✗ | distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1)); | |
| 6662 | |||
| 6663 | //Get the scale of each line based on the distance | ||
| 6664 | |||
| 6665 | ✗ | horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1)); | |
| 6666 | |||
| 6667 | //There was some math here before I stripped out the rotation step | ||
| 6668 | ✗ | line_dx = horizontal_scale; | |
| 6669 | ✗ | line_dy = 0; | |
| 6670 | |||
| 6671 | //space_x,space_y - where to grab each scanline from on the space bitmap | ||
| 6672 | ✗ | space_x = srcX - destW/2.0 * line_dx; | |
| 6673 | ✗ | space_y = srcY - distance + destH/2.0 * line_dy; | |
| 6674 | |||
| 6675 | //Keep blits within the bounds of both bitmaps to avoid crashes | ||
| 6676 | ✗ | int32_t y1 = srcY+space_y; | |
| 6677 | ✗ | int32_t y2 = destY+screen_y; | |
| 6678 | ✗ | if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) ) | |
| 6679 | { | ||
| 6680 | ✗ | if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y), | |
| 6681 | ✗ | (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1); | |
| 6682 | ✗ | else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y), | |
| 6683 | ✗ | (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1); | |
| 6684 | } | ||
| 6685 | } | ||
| 6686 | |||
| 6687 | |||
| 6688 | //cleanup | ||
| 6689 | ✗ | if(subBmp) | |
| 6690 | { | ||
| 6691 | //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap. | ||
| 6692 | ✗ | destroy_bitmap(subBmp); | |
| 6693 | } | ||
| 6694 | } | ||
| 6695 | |||
| 6696 | |||
| 6697 | //Draw]() | ||
| 6698 | ✗ | void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 6699 | { | ||
| 6700 | /* | ||
| 6701 | //sdci[1]=layer | ||
| 6702 | //sdci[2]=bitmap target | ||
| 6703 | // | ||
| 6704 | // -2 is the current Render Target | ||
| 6705 | // -1, this is the screen (framebuf). | ||
| 6706 | // 0: Render target 0 | ||
| 6707 | // 1: Render target 1 | ||
| 6708 | // 2: Render target 2 | ||
| 6709 | // 3: Render target 3 | ||
| 6710 | // 4: Render target 4 | ||
| 6711 | // 5: Render target 5 | ||
| 6712 | // 6: Render target 6 | ||
| 6713 | // Otherwise: The pointer to a bitmap. | ||
| 6714 | |||
| 6715 | //sdci[3]=sourcex | ||
| 6716 | //sdci[4]=sourcey | ||
| 6717 | //sdci[5]=sourcew | ||
| 6718 | //sdci[6]=sourceh | ||
| 6719 | //sdci[7]=destx | ||
| 6720 | //sdci[8]=desty | ||
| 6721 | //sdci[9]=destw | ||
| 6722 | //sdci[10]=desth | ||
| 6723 | //sdci[11]=rotation/angle | ||
| 6724 | //scdi[12] = pivot cx | ||
| 6725 | //sdci[13] = pivot cy | ||
| 6726 | //scdi[14] = effect flags | ||
| 6727 | //sdci[17] Bitmap Pointer | ||
| 6728 | |||
| 6729 | // ZScript-side constant values: | ||
| 6730 | const int32_t BITDX_NORMAL = 0; | ||
| 6731 | const int32_t BITDX_TRANS = 1; //Translucent | ||
| 6732 | const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center. | ||
| 6733 | const int32_t BITDX_HFLIP = 4; //Horizontal Flip | ||
| 6734 | const int32_t BITDX_VFLIP = 8; //Vertical Flip. | ||
| 6735 | //Note: Some modes cannot be combined. if a combination is not supported, an error | ||
| 6736 | // detailing this will be shown in allegro.log. | ||
| 6737 | |||
| 6738 | //scdi[15] = litcolour | ||
| 6739 | //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | ||
| 6740 | //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 6741 | |||
| 6742 | //sdci[16]=mask | ||
| 6743 | |||
| 6744 | */ | ||
| 6745 | |||
| 6746 | ✗ | int32_t bitmapIndex = sdci[2]/10000; | |
| 6747 | ✗ | int32_t usr_bitmap_index = sdci[2]-10; | |
| 6748 | ✗ | byte using_user_bitmap = 0; | |
| 6749 | //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex); | ||
| 6750 | //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex); | ||
| 6751 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6752 | Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex); | ||
| 6753 | #endif | ||
| 6754 | ✗ | if ( bitmapIndex > 10000 ) | |
| 6755 | { | ||
| 6756 | ✗ | bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8; | |
| 6757 | } | ||
| 6758 | ✗ | if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 ) | |
| 6759 | { | ||
| 6760 | ✗ | bitmapIndex = usr_bitmap_index; | |
| 6761 | ✗ | using_user_bitmap = 1; | |
| 6762 | ✗ | yoffset = 0; | |
| 6763 | } | ||
| 6764 | |||
| 6765 | ✗ | int32_t sx = sdci[3]/10000; | |
| 6766 | ✗ | int32_t sy = sdci[4]/10000; | |
| 6767 | ✗ | int32_t sw = sdci[5]/10000; | |
| 6768 | //Z_scripterrlog("sh is: %d\n",sdci[5]/10000); | ||
| 6769 | ✗ | int32_t sh = sdci[6]/10000; | |
| 6770 | //Z_scripterrlog("sh is: %d\n",sdci[6]/10000); | ||
| 6771 | ✗ | int32_t dx = sdci[7]/10000; | |
| 6772 | ✗ | int32_t dy = sdci[8]/10000; | |
| 6773 | ✗ | int32_t dw = sdci[9]/10000; | |
| 6774 | ✗ | int32_t dh = sdci[10]/10000; | |
| 6775 | ✗ | float rot = sdci[11]/10000; | |
| 6776 | ✗ | int32_t cx = sdci[12]/10000; | |
| 6777 | ✗ | int32_t cy = sdci[13]/10000; | |
| 6778 | ✗ | int32_t mode = sdci[14]/10000; | |
| 6779 | ✗ | int32_t litcolour = sdci[15]/10000; | |
| 6780 | ✗ | bool masked = (sdci[16] != 0); | |
| 6781 | |||
| 6782 | ✗ | int32_t ref = 0; | |
| 6783 | |||
| 6784 | ✗ | dx = dx + xoffset; | |
| 6785 | ✗ | dy = dy + yoffset; | |
| 6786 | |||
| 6787 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 6788 | //Do we need to also check the render target and do the same thing if the | ||
| 6789 | //dest == -2 and the render target is not RT_SCREEN? | ||
| 6790 | |||
| 6791 | ✗ | ref = sdci[17]; | |
| 6792 | //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref); | ||
| 6793 | ✗ | ref -=10; | |
| 6794 | //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref); | ||
| 6795 | |||
| 6796 | |||
| 6797 | ✗ | if ( ref <= 0 ) | |
| 6798 | { | ||
| 6799 | ✗ | Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref); | |
| 6800 | ✗ | return; | |
| 6801 | } | ||
| 6802 | ✗ | BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1. | |
| 6803 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6804 | Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]); | ||
| 6805 | #endif | ||
| 6806 | ✗ | if(!sourceBitmap) | |
| 6807 | { | ||
| 6808 | |||
| 6809 | ✗ | Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref); | |
| 6810 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 6811 | ✗ | return; | |
| 6812 | } | ||
| 6813 | |||
| 6814 | ✗ | BITMAP *destBMP=NULL; | |
| 6815 | //zprint2("blit () bitmap index is: %d\n",bitmapIndex); | ||
| 6816 | ✗ | switch(bitmapIndex) | |
| 6817 | { | ||
| 6818 | case -2: | ||
| 6819 | { | ||
| 6820 | ✗ | int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); | |
| 6821 | //zprint2("current RT is: %d\n", curr_rt); | ||
| 6822 | ✗ | if ( curr_rt >= 0 && curr_rt < 7 ) | |
| 6823 | ✗ | destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget. | |
| 6824 | ✗ | else destBMP = bmp; //screen | |
| 6825 | ✗ | break; | |
| 6826 | } | ||
| 6827 | case -1: | ||
| 6828 | ✗ | destBMP = bmp; //this is framebuf, by default | |
| 6829 | ✗ | break; | |
| 6830 | //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex); | ||
| 6831 | //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 6832 | //destBMP = framebuf; //Drawing to the screen. | ||
| 6833 | //break; | ||
| 6834 | |||
| 6835 | //1 through 6 are the old system bitmaps (Render Targets) | ||
| 6836 | case 0: | ||
| 6837 | case 1: | ||
| 6838 | case 2: | ||
| 6839 | case 3: | ||
| 6840 | case 4: | ||
| 6841 | case 5: | ||
| 6842 | case 6: | ||
| 6843 | { | ||
| 6844 | //This gets a render target. | ||
| 6845 | ✗ | destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break; | |
| 6846 | |||
| 6847 | //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex); | ||
| 6848 | //sdci[18] = bitmapIndex; | ||
| 6849 | break; | ||
| 6850 | } | ||
| 6851 | //Otherwise, we are using a user-created bitmap, so, get that pointer insted. | ||
| 6852 | default: | ||
| 6853 | { | ||
| 6854 | ✗ | destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp; | |
| 6855 | //sdci[18] = usr_bitmap_index; | ||
| 6856 | ✗ | if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp ) | |
| 6857 | { | ||
| 6858 | ✗ | Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n"); | |
| 6859 | ✗ | break; | |
| 6860 | } | ||
| 6861 | } | ||
| 6862 | //FFCore.get_user_bitmap(bitmapIndex); break; | ||
| 6863 | } | ||
| 6864 | |||
| 6865 | |||
| 6866 | |||
| 6867 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6868 | Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex); | ||
| 6869 | #endif | ||
| 6870 | |||
| 6871 | |||
| 6872 | ✗ | if (!destBMP) | |
| 6873 | { | ||
| 6874 | |||
| 6875 | ✗ | Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex); | |
| 6876 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 6877 | ✗ | return; | |
| 6878 | } | ||
| 6879 | |||
| 6880 | //bugfix | ||
| 6881 | //sx = vbound(sx, 0, sourceBitmap->w); | ||
| 6882 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6883 | Z_scripterrlog("Blit %s is: %d\n", "sx", sx); | ||
| 6884 | Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w); | ||
| 6885 | #endif | ||
| 6886 | //sy = vbound(sy, 0, sourceBitmap->h); | ||
| 6887 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6888 | Z_scripterrlog("Blit %s is: %d\n", "sy", sy); | ||
| 6889 | Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h); | ||
| 6890 | #endif | ||
| 6891 | //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well | ||
| 6892 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6893 | Z_scripterrlog("Blit %s is: %d\n", "sw", sw); | ||
| 6894 | #endif | ||
| 6895 | //sh = vbound(sh, 0, sourceBitmap->h - sy); | ||
| 6896 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6897 | Z_scripterrlog("Blit %s is: %d\n", "sh", sh); | ||
| 6898 | |||
| 6899 | Z_scripterrlog("Blit %s is: %d\n", "dh", dh); | ||
| 6900 | Z_scripterrlog("Blit %s is: %d\n", "dw", dw); | ||
| 6901 | #endif | ||
| 6902 | ✗ | bool stretched = (sw != dw || sh != dh); | |
| 6903 | //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h); | ||
| 6904 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 6905 | Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false"); | ||
| 6906 | #endif | ||
| 6907 | //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 6908 | |||
| 6909 | |||
| 6910 | |||
| 6911 | |||
| 6912 | |||
| 6913 | ✗ | BITMAP* subBmp = 0; | |
| 6914 | |||
| 6915 | /* IDR what this was. -Z ( 17th April, 2019 ) | ||
| 6916 | if ( bitmapIndex == -1 ) { | ||
| 6917 | blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh); | ||
| 6918 | } | ||
| 6919 | */ | ||
| 6920 | |||
| 6921 | ✗ | if(rot != 0 || mode != 0) | |
| 6922 | { | ||
| 6923 | ✗ | subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh); | |
| 6924 | ✗ | clear_bitmap(subBmp); | |
| 6925 | |||
| 6926 | ✗ | if(!subBmp) | |
| 6927 | { | ||
| 6928 | |||
| 6929 | ✗ | Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation"); | |
| 6930 | ✗ | return; | |
| 6931 | } | ||
| 6932 | } | ||
| 6933 | ✗ | BITMAP* sbmp = sourceBitmap; | |
| 6934 | ✗ | if (sx + sw > sbmp->w || sy + sh > sbmp->h) | |
| 6935 | { | ||
| 6936 | ✗ | sbmp = create_bitmap_ex(8, sw, sh); | |
| 6937 | ✗ | clear_bitmap(sbmp); | |
| 6938 | ✗ | blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh)); | |
| 6939 | ✗ | sx = 0; | |
| 6940 | ✗ | sy = 0; | |
| 6941 | } | ||
| 6942 | //dx = dx + xoffset; //don't do this here! | ||
| 6943 | //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 ) | ||
| 6944 | |||
| 6945 | ✗ | if(stretched) | |
| 6946 | { | ||
| 6947 | ✗ | if(masked) | |
| 6948 | { //stretched and masked | ||
| 6949 | ✗ | if ( rot == 0 ) | |
| 6950 | { //if not rotated | ||
| 6951 | ✗ | switch(mode) | |
| 6952 | { | ||
| 6953 | case 1: | ||
| 6954 | //transparent | ||
| 6955 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6956 | ✗ | draw_trans_sprite(destBMP, subBmp, dx, dy); | |
| 6957 | ✗ | break; | |
| 6958 | |||
| 6959 | |||
| 6960 | case 2: | ||
| 6961 | //pivot? | ||
| 6962 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6963 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 6964 | //Pivoting requires two more args | ||
| 6965 | ✗ | break; | |
| 6966 | |||
| 6967 | case 3: | ||
| 6968 | //pivot + trans | ||
| 6969 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6970 | ✗ | pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 6971 | ✗ | break; | |
| 6972 | |||
| 6973 | case 4: | ||
| 6974 | //flip v | ||
| 6975 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6976 | ✗ | draw_sprite_v_flip(destBMP, subBmp, dx, dy); | |
| 6977 | ✗ | break; | |
| 6978 | |||
| 6979 | case 5: | ||
| 6980 | //trans + v flip | ||
| 6981 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6982 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 6983 | ✗ | break; | |
| 6984 | |||
| 6985 | case 6: | ||
| 6986 | //pivot + v flip | ||
| 6987 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6988 | ✗ | pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 6989 | ✗ | break; | |
| 6990 | |||
| 6991 | case 8: | ||
| 6992 | //vlip h | ||
| 6993 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 6994 | ✗ | draw_sprite_h_flip(destBMP, subBmp, dx, dy); | |
| 6995 | ✗ | break; | |
| 6996 | |||
| 6997 | case 9: | ||
| 6998 | //trans + h flip | ||
| 6999 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7000 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 7001 | ✗ | break; | |
| 7002 | |||
| 7003 | case 10: | ||
| 7004 | //flip H and pivot | ||
| 7005 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7006 | //return error cannot pivot and h flip | ||
| 7007 | ✗ | break; | |
| 7008 | |||
| 7009 | case 12: | ||
| 7010 | //vh flip | ||
| 7011 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7012 | ✗ | draw_sprite_vh_flip(destBMP, subBmp, dx, dy); | |
| 7013 | ✗ | break; | |
| 7014 | |||
| 7015 | case 13: | ||
| 7016 | //trans + vh flip | ||
| 7017 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7018 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 7019 | ✗ | break; | |
| 7020 | |||
| 7021 | case 14: | ||
| 7022 | //pivot and vh flip | ||
| 7023 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7024 | //return error cannot both pivot and vh flip | ||
| 7025 | ✗ | break; | |
| 7026 | |||
| 7027 | case 16: | ||
| 7028 | //lit | ||
| 7029 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7030 | ✗ | draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour); | |
| 7031 | ✗ | break; | |
| 7032 | |||
| 7033 | case 18: | ||
| 7034 | //pivot, lit | ||
| 7035 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7036 | ✗ | pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7037 | ✗ | break; | |
| 7038 | |||
| 7039 | case 20: | ||
| 7040 | //lit + v flip | ||
| 7041 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7042 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 7043 | ✗ | break; | |
| 7044 | |||
| 7045 | case 22: | ||
| 7046 | //Pivot, vflip, lit | ||
| 7047 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7048 | ✗ | pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7049 | ✗ | break; | |
| 7050 | |||
| 7051 | case 24: | ||
| 7052 | //lit + h flip | ||
| 7053 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7054 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 7055 | ✗ | break; | |
| 7056 | |||
| 7057 | case 26: | ||
| 7058 | //pivot + lit + hflip | ||
| 7059 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 7060 | //return error cannot pivot, lit, and flip | ||
| 7061 | ✗ | break; | |
| 7062 | |||
| 7063 | case 28: | ||
| 7064 | //lit + vh flip | ||
| 7065 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7066 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 7067 | ✗ | break; | |
| 7068 | |||
| 7069 | case 32: //gouraud | ||
| 7070 | //Probably not wort supporting. | ||
| 7071 | //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7072 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7073 | ✗ | break; | |
| 7074 | |||
| 7075 | case 0: | ||
| 7076 | //no effect | ||
| 7077 | ✗ | masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 7078 | ✗ | break; | |
| 7079 | |||
| 7080 | |||
| 7081 | default: | ||
| 7082 | |||
| 7083 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7084 | |||
| 7085 | |||
| 7086 | } | ||
| 7087 | } //end if not rotated | ||
| 7088 | |||
| 7089 | ✗ | if ( rot != 0 ) //if rotated | |
| 7090 | { | ||
| 7091 | ✗ | switch(mode) | |
| 7092 | { | ||
| 7093 | case 1: | ||
| 7094 | //transparent | ||
| 7095 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7096 | ✗ | rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7097 | |||
| 7098 | ✗ | break; | |
| 7099 | |||
| 7100 | case 2: | ||
| 7101 | //pivot? | ||
| 7102 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7103 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7104 | //Pivoting requires two more args | ||
| 7105 | ✗ | break; | |
| 7106 | |||
| 7107 | case 3: | ||
| 7108 | //pivot + trans | ||
| 7109 | //return an error, cannot both rotate and pivot | ||
| 7110 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7111 | ✗ | break; | |
| 7112 | |||
| 7113 | case 4: | ||
| 7114 | //flip v | ||
| 7115 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7116 | ✗ | rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7117 | ✗ | break; | |
| 7118 | |||
| 7119 | case 5: | ||
| 7120 | //trans + v flip | ||
| 7121 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7122 | ✗ | rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7123 | ✗ | break; | |
| 7124 | |||
| 7125 | case 6: | ||
| 7126 | //pivot + v flip | ||
| 7127 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7128 | //return an error, cannot both rotate and pivot | ||
| 7129 | ✗ | break; | |
| 7130 | |||
| 7131 | case 8: | ||
| 7132 | //flip h | ||
| 7133 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 7134 | //return an error, cannot both rotate and flip H | ||
| 7135 | ✗ | break; | |
| 7136 | |||
| 7137 | case 9: | ||
| 7138 | //trans + h flip | ||
| 7139 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 7140 | //return an error, cannot rotate and flip a trans sprite | ||
| 7141 | ✗ | break; | |
| 7142 | |||
| 7143 | case 10: | ||
| 7144 | //flip H and pivot | ||
| 7145 | //return error cannot pivot and h flip | ||
| 7146 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7147 | ✗ | break; | |
| 7148 | |||
| 7149 | case 12: | ||
| 7150 | //vh flip | ||
| 7151 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7152 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7153 | ✗ | break; | |
| 7154 | |||
| 7155 | case 13: | ||
| 7156 | //trans + vh flip | ||
| 7157 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7158 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7159 | ✗ | break; | |
| 7160 | |||
| 7161 | case 14: | ||
| 7162 | //pivot and vh flip | ||
| 7163 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7164 | //return error cannot both pivot and vh flip | ||
| 7165 | ✗ | break; | |
| 7166 | |||
| 7167 | case 16: | ||
| 7168 | //lit | ||
| 7169 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7170 | ✗ | rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7171 | ✗ | break; | |
| 7172 | |||
| 7173 | case 18: | ||
| 7174 | //pivot, lit | ||
| 7175 | //return an error, cannot both rotate and pivot | ||
| 7176 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7177 | ✗ | break; | |
| 7178 | |||
| 7179 | case 20: | ||
| 7180 | //lit + vflip | ||
| 7181 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7182 | ✗ | rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7183 | ✗ | break; | |
| 7184 | |||
| 7185 | case 22: | ||
| 7186 | //Pivot, vflip, lit | ||
| 7187 | //return an error, cannot both rotate and pivot | ||
| 7188 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7189 | ✗ | break; | |
| 7190 | |||
| 7191 | case 24: | ||
| 7192 | //lit + h flip | ||
| 7193 | //return an error, cannot both rotate and H flip | ||
| 7194 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 7195 | ✗ | break; | |
| 7196 | |||
| 7197 | case 26: | ||
| 7198 | //pivot + lit + hflip | ||
| 7199 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 7200 | //return error cannot pivot, lit, and flip | ||
| 7201 | ✗ | break; | |
| 7202 | |||
| 7203 | case 28: | ||
| 7204 | //lit + vh flip | ||
| 7205 | //return an error, cannot both rotate and VH flip | ||
| 7206 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7207 | ✗ | break; | |
| 7208 | |||
| 7209 | case 32: //gouraud | ||
| 7210 | //Probably not wort supporting. | ||
| 7211 | //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7212 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7213 | ✗ | break; | |
| 7214 | |||
| 7215 | case 0: | ||
| 7216 | //no effect. | ||
| 7217 | ✗ | masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7218 | ✗ | rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7219 | ✗ | break; | |
| 7220 | |||
| 7221 | default: | ||
| 7222 | |||
| 7223 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7224 | |||
| 7225 | } | ||
| 7226 | } | ||
| 7227 | } //end if stretched and masked | ||
| 7228 | |||
| 7229 | else //stretched, not masked | ||
| 7230 | { | ||
| 7231 | |||
| 7232 | |||
| 7233 | ✗ | if ( rot == 0 ) //if not rotated | |
| 7234 | { | ||
| 7235 | ✗ | switch(mode) | |
| 7236 | { | ||
| 7237 | case 1: | ||
| 7238 | //transparent | ||
| 7239 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7240 | ✗ | draw_trans_sprite(destBMP, subBmp, dx, dy); | |
| 7241 | ✗ | break; | |
| 7242 | |||
| 7243 | |||
| 7244 | case 2: | ||
| 7245 | //pivot? | ||
| 7246 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7247 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7248 | //Pivoting requires two more args | ||
| 7249 | ✗ | break; | |
| 7250 | |||
| 7251 | case 3: | ||
| 7252 | //pivot + trans | ||
| 7253 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7254 | ✗ | pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot)); | |
| 7255 | ✗ | break; | |
| 7256 | |||
| 7257 | case 4: | ||
| 7258 | //flip v | ||
| 7259 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7260 | ✗ | draw_sprite_v_flip(destBMP, subBmp, dx, dy); | |
| 7261 | ✗ | break; | |
| 7262 | |||
| 7263 | case 5: | ||
| 7264 | //trans + v flip | ||
| 7265 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7266 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 7267 | ✗ | break; | |
| 7268 | |||
| 7269 | case 6: | ||
| 7270 | //pivot + v flip | ||
| 7271 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7272 | ✗ | pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7273 | ✗ | break; | |
| 7274 | |||
| 7275 | case 8: | ||
| 7276 | //vlip h | ||
| 7277 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7278 | ✗ | draw_sprite_h_flip(destBMP, subBmp, dx, dy); | |
| 7279 | ✗ | break; | |
| 7280 | |||
| 7281 | case 9: | ||
| 7282 | //trans + h flip | ||
| 7283 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7284 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 7285 | ✗ | break; | |
| 7286 | |||
| 7287 | case 10: | ||
| 7288 | //flip H and pivot | ||
| 7289 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7290 | //return error cannot pivot and h flip | ||
| 7291 | ✗ | break; | |
| 7292 | |||
| 7293 | case 12: | ||
| 7294 | //vh flip | ||
| 7295 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7296 | ✗ | draw_sprite_vh_flip(destBMP, subBmp, dx, dy); | |
| 7297 | ✗ | break; | |
| 7298 | |||
| 7299 | case 13: | ||
| 7300 | //trans + vh flip | ||
| 7301 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7302 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 7303 | ✗ | break; | |
| 7304 | |||
| 7305 | case 14: | ||
| 7306 | //pivot and vh flip | ||
| 7307 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7308 | //return error cannot both pivot and vh flip | ||
| 7309 | ✗ | break; | |
| 7310 | |||
| 7311 | case 16: | ||
| 7312 | //lit | ||
| 7313 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7314 | ✗ | draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour); | |
| 7315 | ✗ | break; | |
| 7316 | |||
| 7317 | case 18: | ||
| 7318 | //pivot, lit | ||
| 7319 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7320 | ✗ | pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7321 | ✗ | break; | |
| 7322 | |||
| 7323 | case 20: | ||
| 7324 | //lit + v flip | ||
| 7325 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7326 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 7327 | ✗ | break; | |
| 7328 | |||
| 7329 | case 22: | ||
| 7330 | //Pivot, vflip, lit | ||
| 7331 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7332 | ✗ | pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7333 | ✗ | break; | |
| 7334 | |||
| 7335 | case 24: | ||
| 7336 | //lit + h flip | ||
| 7337 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7338 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 7339 | ✗ | break; | |
| 7340 | |||
| 7341 | case 26: | ||
| 7342 | //pivot + lit + hflip | ||
| 7343 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 7344 | //return error cannot pivot, lit, and flip | ||
| 7345 | ✗ | break; | |
| 7346 | |||
| 7347 | case 28: | ||
| 7348 | //lit + vh flip | ||
| 7349 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7350 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 7351 | ✗ | break; | |
| 7352 | |||
| 7353 | case 32: //gouraud | ||
| 7354 | //Probably not wort supporting. | ||
| 7355 | //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7356 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7357 | ✗ | break; | |
| 7358 | |||
| 7359 | case 0: | ||
| 7360 | //no effect | ||
| 7361 | ✗ | stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 7362 | ✗ | break; | |
| 7363 | |||
| 7364 | |||
| 7365 | default: | ||
| 7366 | |||
| 7367 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7368 | |||
| 7369 | |||
| 7370 | } | ||
| 7371 | } //end if not rotated | ||
| 7372 | |||
| 7373 | ✗ | if ( rot != 0 ) //if rotated | |
| 7374 | { | ||
| 7375 | ✗ | switch(mode) | |
| 7376 | { | ||
| 7377 | case 1: | ||
| 7378 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 7379 | ✗ | rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7380 | |||
| 7381 | ✗ | break; | |
| 7382 | |||
| 7383 | case 2: | ||
| 7384 | //pivot? | ||
| 7385 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7386 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7387 | //Pivoting requires two more args | ||
| 7388 | ✗ | break; | |
| 7389 | |||
| 7390 | case 3: | ||
| 7391 | //pivot + trans | ||
| 7392 | //return an error, cannot both rotate and pivot | ||
| 7393 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7394 | ✗ | break; | |
| 7395 | |||
| 7396 | case 4: | ||
| 7397 | //flip v | ||
| 7398 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7399 | ✗ | rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7400 | ✗ | break; | |
| 7401 | |||
| 7402 | case 5: | ||
| 7403 | //trans + v flip | ||
| 7404 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7405 | ✗ | rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7406 | ✗ | break; | |
| 7407 | |||
| 7408 | case 6: | ||
| 7409 | //pivot + v flip | ||
| 7410 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7411 | //return an error, cannot both rotate and pivot | ||
| 7412 | ✗ | break; | |
| 7413 | |||
| 7414 | case 8: | ||
| 7415 | //flip h | ||
| 7416 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 7417 | //return an error, cannot both rotate and flip H | ||
| 7418 | ✗ | break; | |
| 7419 | |||
| 7420 | case 9: | ||
| 7421 | //trans + h flip | ||
| 7422 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 7423 | //return an error, cannot rotate and flip a trans sprite | ||
| 7424 | ✗ | break; | |
| 7425 | |||
| 7426 | case 10: | ||
| 7427 | //flip H and pivot | ||
| 7428 | //return error cannot pivot and h flip | ||
| 7429 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7430 | ✗ | break; | |
| 7431 | |||
| 7432 | case 12: | ||
| 7433 | //vh flip | ||
| 7434 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7435 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7436 | ✗ | break; | |
| 7437 | |||
| 7438 | case 13: | ||
| 7439 | //trans + vh flip | ||
| 7440 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7441 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7442 | ✗ | break; | |
| 7443 | |||
| 7444 | case 14: | ||
| 7445 | //pivot and vh flip | ||
| 7446 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7447 | //return error cannot both pivot and vh flip | ||
| 7448 | ✗ | break; | |
| 7449 | |||
| 7450 | case 16: | ||
| 7451 | //lit | ||
| 7452 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 7453 | ✗ | rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7454 | ✗ | break; | |
| 7455 | |||
| 7456 | case 18: | ||
| 7457 | //pivot, lit | ||
| 7458 | //return an error, cannot both rotate and pivot | ||
| 7459 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7460 | ✗ | break; | |
| 7461 | |||
| 7462 | case 20: | ||
| 7463 | //lit + vflip | ||
| 7464 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 7465 | ✗ | rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7466 | ✗ | break; | |
| 7467 | |||
| 7468 | case 22: | ||
| 7469 | //Pivot, vflip, lit | ||
| 7470 | //return an error, cannot both rotate and pivot | ||
| 7471 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7472 | ✗ | break; | |
| 7473 | |||
| 7474 | case 24: | ||
| 7475 | //lit + h flip | ||
| 7476 | //return an error, cannot both rotate and H flip | ||
| 7477 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 7478 | ✗ | break; | |
| 7479 | |||
| 7480 | case 26: | ||
| 7481 | //pivot + lit + hflip | ||
| 7482 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 7483 | //return error cannot pivot, lit, and flip | ||
| 7484 | ✗ | break; | |
| 7485 | |||
| 7486 | case 28: | ||
| 7487 | //lit + vh flip | ||
| 7488 | //return an error, cannot both rotate and VH flip | ||
| 7489 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7490 | ✗ | break; | |
| 7491 | |||
| 7492 | case 32: //gouraud | ||
| 7493 | //Probably not wort supporting. | ||
| 7494 | //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7495 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7496 | ✗ | break; | |
| 7497 | |||
| 7498 | case 0: | ||
| 7499 | //no effect. | ||
| 7500 | ✗ | stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 7501 | ✗ | rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7502 | ✗ | break; | |
| 7503 | |||
| 7504 | default: | ||
| 7505 | |||
| 7506 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7507 | |||
| 7508 | } | ||
| 7509 | } | ||
| 7510 | |||
| 7511 | } //end if stretched, but not masked | ||
| 7512 | } | ||
| 7513 | else //not stretched | ||
| 7514 | { | ||
| 7515 | |||
| 7516 | ✗ | if(masked) //if masked, but not stretched | |
| 7517 | { | ||
| 7518 | |||
| 7519 | ✗ | if ( rot == 0 ) //if not rotated | |
| 7520 | { | ||
| 7521 | ✗ | switch(mode) | |
| 7522 | { | ||
| 7523 | case 1: | ||
| 7524 | //transparent | ||
| 7525 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7526 | ✗ | draw_trans_sprite(destBMP, subBmp, dx, dy); | |
| 7527 | ✗ | break; | |
| 7528 | |||
| 7529 | |||
| 7530 | case 2: | ||
| 7531 | //pivot? | ||
| 7532 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7533 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7534 | //Pivoting requires two more args | ||
| 7535 | ✗ | break; | |
| 7536 | |||
| 7537 | case 3: | ||
| 7538 | //pivot + trans | ||
| 7539 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7540 | ✗ | pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7541 | ✗ | break; | |
| 7542 | |||
| 7543 | case 4: | ||
| 7544 | //flip v | ||
| 7545 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7546 | ✗ | draw_sprite_v_flip(destBMP, subBmp, dx, dy); | |
| 7547 | ✗ | break; | |
| 7548 | |||
| 7549 | case 5: | ||
| 7550 | //trans + v flip | ||
| 7551 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7552 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 7553 | ✗ | break; | |
| 7554 | |||
| 7555 | case 6: | ||
| 7556 | //pivot + v flip | ||
| 7557 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7558 | ✗ | pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7559 | ✗ | break; | |
| 7560 | |||
| 7561 | case 8: | ||
| 7562 | //vlip h | ||
| 7563 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7564 | ✗ | draw_sprite_h_flip(destBMP, subBmp, dx, dy); | |
| 7565 | ✗ | break; | |
| 7566 | |||
| 7567 | case 9: | ||
| 7568 | //trans + h flip | ||
| 7569 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7570 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 7571 | ✗ | break; | |
| 7572 | |||
| 7573 | case 10: | ||
| 7574 | //flip H and pivot | ||
| 7575 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7576 | //return error cannot pivot and h flip | ||
| 7577 | ✗ | break; | |
| 7578 | |||
| 7579 | case 12: | ||
| 7580 | //vh flip | ||
| 7581 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7582 | ✗ | draw_sprite_vh_flip(destBMP, subBmp, dx, dy); | |
| 7583 | ✗ | break; | |
| 7584 | |||
| 7585 | case 13: | ||
| 7586 | //trans + vh flip | ||
| 7587 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7588 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 7589 | ✗ | break; | |
| 7590 | |||
| 7591 | case 14: | ||
| 7592 | //pivot and vh flip | ||
| 7593 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7594 | //return error cannot both pivot and vh flip | ||
| 7595 | ✗ | break; | |
| 7596 | |||
| 7597 | case 16: | ||
| 7598 | //lit | ||
| 7599 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7600 | ✗ | draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour); | |
| 7601 | ✗ | break; | |
| 7602 | |||
| 7603 | case 18: | ||
| 7604 | //pivot, lit | ||
| 7605 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7606 | ✗ | pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7607 | ✗ | break; | |
| 7608 | |||
| 7609 | case 20: | ||
| 7610 | //lit + v flip | ||
| 7611 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7612 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 7613 | ✗ | break; | |
| 7614 | |||
| 7615 | case 22: | ||
| 7616 | //Pivot, vflip, lit | ||
| 7617 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7618 | ✗ | pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7619 | ✗ | break; | |
| 7620 | |||
| 7621 | case 24: | ||
| 7622 | //lit + h flip | ||
| 7623 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7624 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 7625 | ✗ | break; | |
| 7626 | |||
| 7627 | case 26: | ||
| 7628 | //pivot + lit + hflip | ||
| 7629 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 7630 | //return error cannot pivot, lit, and flip | ||
| 7631 | ✗ | break; | |
| 7632 | |||
| 7633 | case 28: | ||
| 7634 | //lit + vh flip | ||
| 7635 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7636 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 7637 | ✗ | break; | |
| 7638 | |||
| 7639 | case 32: //gouraud | ||
| 7640 | //Probably not wort supporting. | ||
| 7641 | //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7642 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7643 | ✗ | break; | |
| 7644 | |||
| 7645 | case 0: | ||
| 7646 | //no effect | ||
| 7647 | ✗ | masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh); | |
| 7648 | ✗ | break; | |
| 7649 | |||
| 7650 | |||
| 7651 | default: | ||
| 7652 | |||
| 7653 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7654 | |||
| 7655 | |||
| 7656 | } | ||
| 7657 | } //end if not rotated | ||
| 7658 | |||
| 7659 | ✗ | if ( rot != 0 ) //if rotated | |
| 7660 | { | ||
| 7661 | ✗ | switch(mode) | |
| 7662 | { | ||
| 7663 | case 1: | ||
| 7664 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent | |
| 7665 | ✗ | rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7666 | |||
| 7667 | ✗ | break; | |
| 7668 | |||
| 7669 | case 2: | ||
| 7670 | //pivot? | ||
| 7671 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7672 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7673 | //Pivoting requires two more args | ||
| 7674 | ✗ | break; | |
| 7675 | |||
| 7676 | case 3: | ||
| 7677 | //pivot + trans | ||
| 7678 | //return an error, cannot both rotate and pivot | ||
| 7679 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7680 | ✗ | break; | |
| 7681 | |||
| 7682 | case 4: | ||
| 7683 | //flip v | ||
| 7684 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7685 | ✗ | rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7686 | ✗ | break; | |
| 7687 | |||
| 7688 | case 5: | ||
| 7689 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip | |
| 7690 | ✗ | rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7691 | ✗ | break; | |
| 7692 | |||
| 7693 | case 6: | ||
| 7694 | //pivot + v flip | ||
| 7695 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7696 | //return an error, cannot both rotate and pivot | ||
| 7697 | ✗ | break; | |
| 7698 | |||
| 7699 | case 8: | ||
| 7700 | //flip h | ||
| 7701 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 7702 | //return an error, cannot both rotate and flip H | ||
| 7703 | ✗ | break; | |
| 7704 | |||
| 7705 | case 9: | ||
| 7706 | //trans + h flip | ||
| 7707 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 7708 | //return an error, cannot rotate and flip a trans sprite | ||
| 7709 | ✗ | break; | |
| 7710 | |||
| 7711 | case 10: | ||
| 7712 | //flip H and pivot | ||
| 7713 | //return error cannot pivot and h flip | ||
| 7714 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7715 | ✗ | break; | |
| 7716 | |||
| 7717 | case 12: | ||
| 7718 | //vh flip | ||
| 7719 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7720 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7721 | ✗ | break; | |
| 7722 | |||
| 7723 | case 13: | ||
| 7724 | //trans + vh flip | ||
| 7725 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 7726 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 7727 | ✗ | break; | |
| 7728 | |||
| 7729 | case 14: | ||
| 7730 | //pivot and vh flip | ||
| 7731 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7732 | //return error cannot both pivot and vh flip | ||
| 7733 | ✗ | break; | |
| 7734 | |||
| 7735 | case 16: | ||
| 7736 | //lit | ||
| 7737 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7738 | ✗ | rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7739 | ✗ | break; | |
| 7740 | |||
| 7741 | case 18: | ||
| 7742 | //pivot, lit | ||
| 7743 | //return an error, cannot both rotate and pivot | ||
| 7744 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7745 | ✗ | break; | |
| 7746 | |||
| 7747 | case 20: | ||
| 7748 | //lit + vflip | ||
| 7749 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7750 | ✗ | rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 7751 | ✗ | break; | |
| 7752 | |||
| 7753 | case 22: | ||
| 7754 | //Pivot, vflip, lit | ||
| 7755 | //return an error, cannot both rotate and pivot | ||
| 7756 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 7757 | ✗ | break; | |
| 7758 | |||
| 7759 | case 24: | ||
| 7760 | //lit + h flip | ||
| 7761 | //return an error, cannot both rotate and H flip | ||
| 7762 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 7763 | ✗ | break; | |
| 7764 | |||
| 7765 | case 26: | ||
| 7766 | //pivot + lit + hflip | ||
| 7767 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 7768 | //return error cannot pivot, lit, and flip | ||
| 7769 | ✗ | break; | |
| 7770 | |||
| 7771 | case 28: | ||
| 7772 | //lit + vh flip | ||
| 7773 | //return an error, cannot both rotate and VH flip | ||
| 7774 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7775 | ✗ | break; | |
| 7776 | |||
| 7777 | case 32: //gouraud | ||
| 7778 | //Probably not wort supporting. | ||
| 7779 | //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 7780 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7781 | ✗ | break; | |
| 7782 | |||
| 7783 | case 0: | ||
| 7784 | //no effect. | ||
| 7785 | ✗ | masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7786 | ✗ | rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7787 | ✗ | break; | |
| 7788 | |||
| 7789 | default: | ||
| 7790 | |||
| 7791 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7792 | |||
| 7793 | } | ||
| 7794 | } //end rtated, masked | ||
| 7795 | } //end if masked | ||
| 7796 | |||
| 7797 | else //not masked, and not stretched; just blit | ||
| 7798 | { | ||
| 7799 | |||
| 7800 | ✗ | if ( rot == 0 ) //if not rotated | |
| 7801 | { | ||
| 7802 | ✗ | switch(mode) | |
| 7803 | { | ||
| 7804 | case 1: | ||
| 7805 | //transparent | ||
| 7806 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7807 | ✗ | draw_trans_sprite(destBMP, subBmp, dx, dy); | |
| 7808 | ✗ | break; | |
| 7809 | |||
| 7810 | |||
| 7811 | case 2: | ||
| 7812 | //pivot? | ||
| 7813 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7814 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7815 | //Pivoting requires two more args | ||
| 7816 | ✗ | break; | |
| 7817 | |||
| 7818 | case 3: | ||
| 7819 | //pivot + trans | ||
| 7820 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7821 | ✗ | pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7822 | ✗ | break; | |
| 7823 | |||
| 7824 | case 4: | ||
| 7825 | //flip v | ||
| 7826 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7827 | ✗ | draw_sprite_v_flip(destBMP, subBmp, dx, dy); | |
| 7828 | ✗ | break; | |
| 7829 | |||
| 7830 | case 5: | ||
| 7831 | //trans + v flip | ||
| 7832 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7833 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 7834 | ✗ | break; | |
| 7835 | |||
| 7836 | case 6: | ||
| 7837 | //pivot + v flip | ||
| 7838 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7839 | ✗ | pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7840 | ✗ | break; | |
| 7841 | |||
| 7842 | case 8: | ||
| 7843 | //vlip h | ||
| 7844 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7845 | ✗ | draw_sprite_h_flip(destBMP, subBmp, dx, dy); | |
| 7846 | ✗ | break; | |
| 7847 | |||
| 7848 | case 9: | ||
| 7849 | //trans + h flip | ||
| 7850 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7851 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 7852 | ✗ | break; | |
| 7853 | |||
| 7854 | case 10: | ||
| 7855 | //flip H and pivot | ||
| 7856 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7857 | //return error cannot pivot and h flip | ||
| 7858 | ✗ | break; | |
| 7859 | |||
| 7860 | case 12: | ||
| 7861 | //vh flip | ||
| 7862 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7863 | ✗ | draw_sprite_vh_flip(destBMP, subBmp, dx, dy); | |
| 7864 | ✗ | break; | |
| 7865 | |||
| 7866 | case 13: | ||
| 7867 | //trans + vh flip | ||
| 7868 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7869 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 7870 | ✗ | break; | |
| 7871 | |||
| 7872 | case 14: | ||
| 7873 | //pivot and vh flip | ||
| 7874 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 7875 | //return error cannot both pivot and vh flip | ||
| 7876 | ✗ | break; | |
| 7877 | |||
| 7878 | case 16: | ||
| 7879 | //lit | ||
| 7880 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7881 | ✗ | draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour); | |
| 7882 | ✗ | break; | |
| 7883 | |||
| 7884 | case 18: | ||
| 7885 | //pivot, lit | ||
| 7886 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7887 | ✗ | pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7888 | ✗ | break; | |
| 7889 | |||
| 7890 | case 20: | ||
| 7891 | //lit + v flip | ||
| 7892 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7893 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 7894 | ✗ | break; | |
| 7895 | |||
| 7896 | case 22: | ||
| 7897 | //Pivot, vflip, lit | ||
| 7898 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7899 | ✗ | pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 7900 | ✗ | break; | |
| 7901 | |||
| 7902 | case 24: | ||
| 7903 | //lit + h flip | ||
| 7904 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7905 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 7906 | ✗ | break; | |
| 7907 | |||
| 7908 | case 26: | ||
| 7909 | //pivot + lit + hflip | ||
| 7910 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 7911 | //return error cannot pivot, lit, and flip | ||
| 7912 | ✗ | break; | |
| 7913 | |||
| 7914 | case 28: | ||
| 7915 | //lit + vh flip | ||
| 7916 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7917 | ✗ | draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 7918 | ✗ | break; | |
| 7919 | |||
| 7920 | case 32: //gouraud | ||
| 7921 | //Probably not wort supporting. | ||
| 7922 | //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 7923 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 7924 | ✗ | break; | |
| 7925 | |||
| 7926 | case 0: | ||
| 7927 | //no effect | ||
| 7928 | ✗ | blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh); | |
| 7929 | ✗ | break; | |
| 7930 | |||
| 7931 | |||
| 7932 | default: | ||
| 7933 | |||
| 7934 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 7935 | |||
| 7936 | |||
| 7937 | } | ||
| 7938 | } //end if not rotated | ||
| 7939 | |||
| 7940 | ✗ | if ( rot != 0 ) //if rotated | |
| 7941 | { | ||
| 7942 | ✗ | switch(mode) | |
| 7943 | { | ||
| 7944 | case 1: | ||
| 7945 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent | |
| 7946 | ✗ | rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7947 | |||
| 7948 | ✗ | break; | |
| 7949 | |||
| 7950 | case 2: | ||
| 7951 | //pivot? | ||
| 7952 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7953 | ✗ | pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 7954 | //Pivoting requires two more args | ||
| 7955 | ✗ | break; | |
| 7956 | |||
| 7957 | case 3: | ||
| 7958 | //pivot + trans | ||
| 7959 | //return an error, cannot both rotate and pivot | ||
| 7960 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7961 | ✗ | break; | |
| 7962 | |||
| 7963 | case 4: | ||
| 7964 | //flip v | ||
| 7965 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7966 | ✗ | rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7967 | ✗ | break; | |
| 7968 | |||
| 7969 | case 5: | ||
| 7970 | //trans + v flip | ||
| 7971 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 7972 | ✗ | rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 7973 | ✗ | break; | |
| 7974 | |||
| 7975 | case 6: | ||
| 7976 | //pivot + v flip | ||
| 7977 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 7978 | //return an error, cannot both rotate and pivot | ||
| 7979 | ✗ | break; | |
| 7980 | |||
| 7981 | case 8: | ||
| 7982 | //flip h | ||
| 7983 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 7984 | //return an error, cannot both rotate and flip H | ||
| 7985 | ✗ | break; | |
| 7986 | |||
| 7987 | case 9: | ||
| 7988 | //trans + h flip | ||
| 7989 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 7990 | //return an error, cannot rotate and flip a trans sprite | ||
| 7991 | ✗ | break; | |
| 7992 | |||
| 7993 | case 10: | ||
| 7994 | //flip H and pivot | ||
| 7995 | //return error cannot pivot and h flip | ||
| 7996 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 7997 | ✗ | break; | |
| 7998 | |||
| 7999 | case 12: | ||
| 8000 | //vh flip | ||
| 8001 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8002 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8003 | ✗ | break; | |
| 8004 | |||
| 8005 | case 13: | ||
| 8006 | //trans + vh flip | ||
| 8007 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8008 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8009 | ✗ | break; | |
| 8010 | |||
| 8011 | case 14: | ||
| 8012 | //pivot and vh flip | ||
| 8013 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8014 | //return error cannot both pivot and vh flip | ||
| 8015 | ✗ | break; | |
| 8016 | |||
| 8017 | case 16: | ||
| 8018 | //lit | ||
| 8019 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8020 | ✗ | rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8021 | ✗ | break; | |
| 8022 | |||
| 8023 | case 18: | ||
| 8024 | //pivot, lit | ||
| 8025 | //return an error, cannot both rotate and pivot | ||
| 8026 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8027 | ✗ | break; | |
| 8028 | |||
| 8029 | case 20: | ||
| 8030 | //lit + vflip | ||
| 8031 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8032 | ✗ | rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8033 | ✗ | break; | |
| 8034 | |||
| 8035 | case 22: | ||
| 8036 | //Pivot, vflip, lit | ||
| 8037 | //return an error, cannot both rotate and pivot | ||
| 8038 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8039 | ✗ | break; | |
| 8040 | |||
| 8041 | case 24: | ||
| 8042 | //lit + h flip | ||
| 8043 | //return an error, cannot both rotate and H flip | ||
| 8044 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 8045 | ✗ | break; | |
| 8046 | |||
| 8047 | case 26: | ||
| 8048 | //pivot + lit + hflip | ||
| 8049 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 8050 | //return error cannot pivot, lit, and flip | ||
| 8051 | ✗ | break; | |
| 8052 | |||
| 8053 | case 28: | ||
| 8054 | //lit + vh flip | ||
| 8055 | //return an error, cannot both rotate and VH flip | ||
| 8056 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8057 | ✗ | break; | |
| 8058 | |||
| 8059 | case 32: //gouraud | ||
| 8060 | //Probably not wort supporting. | ||
| 8061 | //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 8062 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 8063 | ✗ | break; | |
| 8064 | |||
| 8065 | case 0: | ||
| 8066 | //no effect. | ||
| 8067 | ✗ | blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8068 | ✗ | rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8069 | ✗ | break; | |
| 8070 | |||
| 8071 | default: | ||
| 8072 | |||
| 8073 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 8074 | |||
| 8075 | } | ||
| 8076 | } //end if rotated | ||
| 8077 | } //end if not masked | ||
| 8078 | } //end if not stretched | ||
| 8079 | |||
| 8080 | //cleanup | ||
| 8081 | ✗ | if(subBmp) | |
| 8082 | { | ||
| 8083 | //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap. | ||
| 8084 | ✗ | destroy_bitmap(subBmp); | |
| 8085 | } | ||
| 8086 | ✗ | if (sbmp != sourceBitmap) | |
| 8087 | { | ||
| 8088 | ✗ | destroy_bitmap(sbmp); | |
| 8089 | } | ||
| 8090 | } | ||
| 8091 | |||
| 8092 | |||
| 8093 | |||
| 8094 | ✗ | void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 8095 | { | ||
| 8096 | /* | ||
| 8097 | //sdci[1]=layer | ||
| 8098 | //sdci[2]=bitmap target | ||
| 8099 | // | ||
| 8100 | // -2 is the current Render Target | ||
| 8101 | // -1, this is the screen (framebuf). | ||
| 8102 | // 0: Render target 0 | ||
| 8103 | // 1: Render target 1 | ||
| 8104 | // 2: Render target 2 | ||
| 8105 | // 3: Render target 3 | ||
| 8106 | // 4: Render target 4 | ||
| 8107 | // 5: Render target 5 | ||
| 8108 | // 6: Render target 6 | ||
| 8109 | // Otherwise: The pointer to a bitmap. | ||
| 8110 | |||
| 8111 | //sdci[3]=sourcex | ||
| 8112 | //sdci[4]=sourcey | ||
| 8113 | //sdci[5]=sourcew | ||
| 8114 | //sdci[6]=sourceh | ||
| 8115 | //sdci[7]=destx | ||
| 8116 | //sdci[8]=desty | ||
| 8117 | //sdci[9]=destw | ||
| 8118 | //sdci[10]=desth | ||
| 8119 | //sdci[11]=rotation/angle | ||
| 8120 | //scdi[12] = pivot cx | ||
| 8121 | //sdci[13] = pivot cy | ||
| 8122 | //scdi[14] = effect flags | ||
| 8123 | //sdci[17] Bitmap Pointer | ||
| 8124 | |||
| 8125 | // ZScript-side constant values: | ||
| 8126 | const int32_t BITDX_NORMAL = 0; | ||
| 8127 | const int32_t BITDX_TRANS = 1; //Translucent | ||
| 8128 | const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center. | ||
| 8129 | const int32_t BITDX_HFLIP = 4; //Horizontal Flip | ||
| 8130 | const int32_t BITDX_VFLIP = 8; //Vertical Flip. | ||
| 8131 | //Note: Some modes cannot be combined. if a combination is not supported, an error | ||
| 8132 | // detailing this will be shown in allegro.log. | ||
| 8133 | |||
| 8134 | //scdi[15] = litcolour | ||
| 8135 | //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | ||
| 8136 | //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot)); | ||
| 8137 | |||
| 8138 | //sdci[16]=mask | ||
| 8139 | |||
| 8140 | */ | ||
| 8141 | |||
| 8142 | ✗ | int32_t srcyoffset = yoffset, srcxoffset = xoffset; | |
| 8143 | ✗ | int32_t bitmapIndex = sdci[2]/10000; | |
| 8144 | ✗ | int32_t usr_bitmap_index = sdci[2]-10; | |
| 8145 | ✗ | byte using_user_bitmap = 0; | |
| 8146 | //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex); | ||
| 8147 | //Z_scripterrlog("Blit() bitmapIndex is: %d\n", bitmapIndex); | ||
| 8148 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8149 | Z_scripterrlog("Blit() found a dest bitmap ID of: %d\n",bitmapIndex); | ||
| 8150 | #endif | ||
| 8151 | ✗ | if ( bitmapIndex > 10000 ) | |
| 8152 | { | ||
| 8153 | ✗ | bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8; | |
| 8154 | } | ||
| 8155 | ✗ | if ( usr_bitmap_index > 0 && usr_bitmap_index < 10000 ) | |
| 8156 | { | ||
| 8157 | ✗ | bitmapIndex = usr_bitmap_index; | |
| 8158 | ✗ | using_user_bitmap = 1; | |
| 8159 | ✗ | srcyoffset = 0; | |
| 8160 | } | ||
| 8161 | |||
| 8162 | ✗ | int32_t sx = sdci[3]/10000; | |
| 8163 | ✗ | int32_t sy = sdci[4]/10000; | |
| 8164 | ✗ | int32_t sw = sdci[5]/10000; | |
| 8165 | //Z_scripterrlog("sh is: %d\n",sdci[5]/10000); | ||
| 8166 | ✗ | int32_t sh = sdci[6]/10000; | |
| 8167 | //Z_scripterrlog("sh is: %d\n",sdci[6]/10000); | ||
| 8168 | ✗ | int32_t dx = sdci[7]/10000; | |
| 8169 | ✗ | int32_t dy = sdci[8]/10000; | |
| 8170 | ✗ | int32_t dw = sdci[9]/10000; | |
| 8171 | ✗ | int32_t dh = sdci[10]/10000; | |
| 8172 | ✗ | float rot = sdci[11]/10000; | |
| 8173 | ✗ | int32_t cx = sdci[12]/10000; | |
| 8174 | ✗ | int32_t cy = sdci[13]/10000; | |
| 8175 | ✗ | int32_t mode = sdci[14]/10000; | |
| 8176 | ✗ | int32_t litcolour = sdci[15]/10000; | |
| 8177 | ✗ | bool masked = (sdci[16] != 0); | |
| 8178 | |||
| 8179 | ✗ | int32_t ref = 0; | |
| 8180 | |||
| 8181 | //These should go down farther, should they not? -V | ||
| 8182 | //dx = dx + xoffset; | ||
| 8183 | //dy = dy + yoffset; | ||
| 8184 | |||
| 8185 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 8186 | ✗ | if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop. | |
| 8187 | //Do we need to also check the render target and do the same thing if the | ||
| 8188 | //dest == -2 and the render target is not RT_SCREEN? | ||
| 8189 | ✗ | dx = dx + xoffset; | |
| 8190 | ✗ | dy = dy + yoffset; | |
| 8191 | ✗ | sx = sx + srcxoffset; | |
| 8192 | ✗ | sy = sy + srcyoffset; | |
| 8193 | |||
| 8194 | ✗ | ref = sdci[17]; | |
| 8195 | //Z_scripterrlog("bitmap->blit() ref id this frame is: %d\n", ref); | ||
| 8196 | ✗ | ref -=10; | |
| 8197 | //Z_scripterrlog("bitmap->blit() modified ref id this frame is: %d\n", ref); | ||
| 8198 | |||
| 8199 | |||
| 8200 | ✗ | if ( ref <= 0 ) | |
| 8201 | { | ||
| 8202 | ✗ | Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref); | |
| 8203 | ✗ | return; | |
| 8204 | } | ||
| 8205 | ✗ | BITMAP *sourceBitmap = FFCore.GetScriptBitmap(ref); //This can be the screen, as -1. | |
| 8206 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8207 | Z_scripterrlog("bitmap->Blit() is trying to blit to ref: %d\n",sdci[17]); | ||
| 8208 | #endif | ||
| 8209 | ✗ | if(!sourceBitmap) | |
| 8210 | { | ||
| 8211 | ✗ | Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref); | |
| 8212 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 8213 | ✗ | return; | |
| 8214 | } | ||
| 8215 | |||
| 8216 | ✗ | BITMAP *destBMP=NULL; | |
| 8217 | //zprint2("RevBlit bitmap index is: %d\n",bitmapIndex); | ||
| 8218 | |||
| 8219 | ✗ | switch(bitmapIndex) | |
| 8220 | { | ||
| 8221 | case -2: | ||
| 8222 | { | ||
| 8223 | ✗ | int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); | |
| 8224 | //zprint2("current RT is: %d\n", curr_rt); | ||
| 8225 | ✗ | if ( curr_rt >= 0 && curr_rt < 7 ) | |
| 8226 | ✗ | destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget. | |
| 8227 | ✗ | else destBMP = bmp; //screen | |
| 8228 | ✗ | break; | |
| 8229 | } | ||
| 8230 | case -1: | ||
| 8231 | ✗ | destBMP = bmp; //this is framebuf, by default | |
| 8232 | ✗ | break; | |
| 8233 | //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex); | ||
| 8234 | //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 8235 | //destBMP = framebuf; //Drawing to the screen. | ||
| 8236 | //break; | ||
| 8237 | |||
| 8238 | //1 through 6 are the old system bitmaps (Render Targets) | ||
| 8239 | case 0: | ||
| 8240 | case 1: | ||
| 8241 | case 2: | ||
| 8242 | case 3: | ||
| 8243 | case 4: | ||
| 8244 | case 5: | ||
| 8245 | case 6: | ||
| 8246 | { | ||
| 8247 | //This gets a render target. | ||
| 8248 | //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break; | ||
| 8249 | |||
| 8250 | ✗ | destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex); | |
| 8251 | //sdci[18] = bitmapIndex; | ||
| 8252 | ✗ | break; | |
| 8253 | } | ||
| 8254 | //Otherwise, we are using a user-created bitmap, so, get that pointer insted. | ||
| 8255 | default: | ||
| 8256 | { | ||
| 8257 | ✗ | destBMP = scb.script_created_bitmaps[usr_bitmap_index].u_bmp; | |
| 8258 | //sdci[18] = usr_bitmap_index; | ||
| 8259 | ✗ | if ( !scb.script_created_bitmaps[usr_bitmap_index].u_bmp ) | |
| 8260 | { | ||
| 8261 | ✗ | Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n"); | |
| 8262 | ✗ | break; | |
| 8263 | } | ||
| 8264 | } | ||
| 8265 | //FFCore.get_user_bitmap(bitmapIndex); break; | ||
| 8266 | } | ||
| 8267 | |||
| 8268 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8269 | Z_scripterrlog("bitmap->Blit() is trying to blit to dest bitmap ID: %d\n",bitmapIndex); | ||
| 8270 | #endif | ||
| 8271 | |||
| 8272 | |||
| 8273 | ✗ | if (!destBMP) | |
| 8274 | { | ||
| 8275 | ✗ | Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex); | |
| 8276 | ✗ | Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n"); | |
| 8277 | ✗ | return; | |
| 8278 | } | ||
| 8279 | |||
| 8280 | //bugfix | ||
| 8281 | //sx = vbound(sx, 0, sourceBitmap->w); | ||
| 8282 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8283 | Z_scripterrlog("Blit %s is: %d\n", "sx", sx); | ||
| 8284 | Z_scripterrlog("Blit %s is: %d\n", "source->w", sourceBitmap->w); | ||
| 8285 | #endif | ||
| 8286 | //sy = vbound(sy, 0, sourceBitmap->h); | ||
| 8287 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8288 | Z_scripterrlog("Blit %s is: %d\n", "sy", sy); | ||
| 8289 | Z_scripterrlog("Blit %s is: %d\n", "source->h", sourceBitmap->h); | ||
| 8290 | #endif | ||
| 8291 | //sw = vbound(sw, 0, sourceBitmap->w - sx); //keep the w/h within range as well | ||
| 8292 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8293 | Z_scripterrlog("Blit %s is: %d\n", "sw", sw); | ||
| 8294 | #endif | ||
| 8295 | //sh = vbound(sh, 0, sourceBitmap->h - sy); | ||
| 8296 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8297 | Z_scripterrlog("Blit %s is: %d\n", "sh", sh); | ||
| 8298 | |||
| 8299 | Z_scripterrlog("Blit %s is: %d\n", "dx", dx); | ||
| 8300 | Z_scripterrlog("Blit %s is: %d\n", "dy", dy); | ||
| 8301 | Z_scripterrlog("Blit %s is: %d\n", "dh", dh); | ||
| 8302 | Z_scripterrlog("Blit %s is: %d\n", "dw", dw); | ||
| 8303 | Z_scripterrlog("Blit %s is: %d\n", "yoffset", yoffset); | ||
| 8304 | #endif | ||
| 8305 | ✗ | bool stretched = (sw != dw || sh != dh); | |
| 8306 | //bool stretched = (sourceBitmap->w != destBMP->w || sourceBitmap->h != destBMP->h); | ||
| 8307 | #if LOG_BMPBLIT_LEVEL > 0 | ||
| 8308 | Z_scripterrlog("Blit %s is: %s\n", "stretched", stretched ? "true" : "false"); | ||
| 8309 | #endif | ||
| 8310 | //BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); | ||
| 8311 | |||
| 8312 | |||
| 8313 | |||
| 8314 | ✗ | BITMAP* newDest = sourceBitmap; | |
| 8315 | ✗ | BITMAP* newSource = destBMP; //Flip them. | |
| 8316 | |||
| 8317 | ✗ | BITMAP* subBmp = 0; | |
| 8318 | |||
| 8319 | /* IDR what this was. -Z ( 17th April, 2019 ) | ||
| 8320 | if ( bitmapIndex == -1 ) { | ||
| 8321 | blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh); | ||
| 8322 | } | ||
| 8323 | */ | ||
| 8324 | |||
| 8325 | ✗ | if(rot != 0 || mode != 0) | |
| 8326 | { | ||
| 8327 | ✗ | subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh); | |
| 8328 | ✗ | clear_bitmap(subBmp); | |
| 8329 | |||
| 8330 | ✗ | if(!subBmp) | |
| 8331 | { | ||
| 8332 | ✗ | Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation"); | |
| 8333 | ✗ | return; | |
| 8334 | } | ||
| 8335 | } | ||
| 8336 | |||
| 8337 | ✗ | if (sx + sw > destBMP->w || sy + sh > destBMP->h) | |
| 8338 | { | ||
| 8339 | ✗ | newSource = create_bitmap_ex(8, sw, sh); | |
| 8340 | ✗ | clear_bitmap(newSource); | |
| 8341 | ✗ | blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh)); | |
| 8342 | ✗ | sx = 0; | |
| 8343 | ✗ | sy = 0; | |
| 8344 | } | ||
| 8345 | //dx = dx + xoffset; //don't do this here! | ||
| 8346 | //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 ) | ||
| 8347 | |||
| 8348 | ✗ | if(stretched) | |
| 8349 | { | ||
| 8350 | ✗ | if(masked) | |
| 8351 | { //stretched and masked | ||
| 8352 | ✗ | if ( rot == 0 ) | |
| 8353 | { //if not rotated | ||
| 8354 | ✗ | switch(mode) | |
| 8355 | { | ||
| 8356 | case 1: | ||
| 8357 | //transparent | ||
| 8358 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8359 | ✗ | draw_trans_sprite(newDest, subBmp, dx, dy); | |
| 8360 | ✗ | break; | |
| 8361 | |||
| 8362 | |||
| 8363 | case 2: | ||
| 8364 | //pivot? | ||
| 8365 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8366 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8367 | //Pivoting requires two more args | ||
| 8368 | ✗ | break; | |
| 8369 | |||
| 8370 | case 3: | ||
| 8371 | //pivot + trans | ||
| 8372 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8373 | ✗ | pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8374 | ✗ | break; | |
| 8375 | |||
| 8376 | case 4: | ||
| 8377 | //flip v | ||
| 8378 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8379 | ✗ | draw_sprite_v_flip(newDest, subBmp, dx, dy); | |
| 8380 | ✗ | break; | |
| 8381 | |||
| 8382 | case 5: | ||
| 8383 | //trans + v flip | ||
| 8384 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8385 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 8386 | ✗ | break; | |
| 8387 | |||
| 8388 | case 6: | ||
| 8389 | //pivot + v flip | ||
| 8390 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8391 | ✗ | pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8392 | ✗ | break; | |
| 8393 | |||
| 8394 | case 8: | ||
| 8395 | //vlip h | ||
| 8396 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8397 | ✗ | draw_sprite_h_flip(newDest, subBmp, dx, dy); | |
| 8398 | ✗ | break; | |
| 8399 | |||
| 8400 | case 9: | ||
| 8401 | //trans + h flip | ||
| 8402 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8403 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 8404 | ✗ | break; | |
| 8405 | |||
| 8406 | case 10: | ||
| 8407 | //flip H and pivot | ||
| 8408 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 8409 | //return error cannot pivot and h flip | ||
| 8410 | ✗ | break; | |
| 8411 | |||
| 8412 | case 12: | ||
| 8413 | //vh flip | ||
| 8414 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8415 | ✗ | draw_sprite_vh_flip(newDest, subBmp, dx, dy); | |
| 8416 | ✗ | break; | |
| 8417 | |||
| 8418 | case 13: | ||
| 8419 | //trans + vh flip | ||
| 8420 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8421 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 8422 | ✗ | break; | |
| 8423 | |||
| 8424 | case 14: | ||
| 8425 | //pivot and vh flip | ||
| 8426 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8427 | //return error cannot both pivot and vh flip | ||
| 8428 | ✗ | break; | |
| 8429 | |||
| 8430 | case 16: | ||
| 8431 | //lit | ||
| 8432 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8433 | ✗ | draw_lit_sprite(newDest, subBmp, dx, dy, litcolour); | |
| 8434 | ✗ | break; | |
| 8435 | |||
| 8436 | case 18: | ||
| 8437 | //pivot, lit | ||
| 8438 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8439 | ✗ | pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 8440 | ✗ | break; | |
| 8441 | |||
| 8442 | case 20: | ||
| 8443 | //lit + v flip | ||
| 8444 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8445 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 8446 | ✗ | break; | |
| 8447 | |||
| 8448 | case 22: | ||
| 8449 | //Pivot, vflip, lit | ||
| 8450 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8451 | ✗ | pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 8452 | ✗ | break; | |
| 8453 | |||
| 8454 | case 24: | ||
| 8455 | //lit + h flip | ||
| 8456 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8457 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 8458 | ✗ | break; | |
| 8459 | |||
| 8460 | case 26: | ||
| 8461 | //pivot + lit + hflip | ||
| 8462 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 8463 | //return error cannot pivot, lit, and flip | ||
| 8464 | ✗ | break; | |
| 8465 | |||
| 8466 | case 28: | ||
| 8467 | //lit + vh flip | ||
| 8468 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8469 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 8470 | ✗ | break; | |
| 8471 | |||
| 8472 | case 32: //gouraud | ||
| 8473 | //Probably not wort supporting. | ||
| 8474 | //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 8475 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 8476 | ✗ | break; | |
| 8477 | |||
| 8478 | case 0: | ||
| 8479 | //no effect | ||
| 8480 | ✗ | masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 8481 | ✗ | break; | |
| 8482 | |||
| 8483 | |||
| 8484 | default: | ||
| 8485 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 8486 | |||
| 8487 | |||
| 8488 | } | ||
| 8489 | } //end if not rotated | ||
| 8490 | |||
| 8491 | ✗ | if ( rot != 0 ) //if rotated | |
| 8492 | { | ||
| 8493 | ✗ | switch(mode) | |
| 8494 | { | ||
| 8495 | case 1: | ||
| 8496 | //transparent | ||
| 8497 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8498 | ✗ | rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8499 | |||
| 8500 | ✗ | break; | |
| 8501 | |||
| 8502 | case 2: | ||
| 8503 | //pivot? | ||
| 8504 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8505 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8506 | //Pivoting requires two more args | ||
| 8507 | ✗ | break; | |
| 8508 | |||
| 8509 | case 3: | ||
| 8510 | //pivot + trans | ||
| 8511 | //return an error, cannot both rotate and pivot | ||
| 8512 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8513 | ✗ | break; | |
| 8514 | |||
| 8515 | case 4: | ||
| 8516 | //flip v | ||
| 8517 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8518 | ✗ | rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8519 | ✗ | break; | |
| 8520 | |||
| 8521 | case 5: | ||
| 8522 | //trans + v flip | ||
| 8523 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8524 | ✗ | rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8525 | ✗ | break; | |
| 8526 | |||
| 8527 | case 6: | ||
| 8528 | //pivot + v flip | ||
| 8529 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8530 | //return an error, cannot both rotate and pivot | ||
| 8531 | ✗ | break; | |
| 8532 | |||
| 8533 | case 8: | ||
| 8534 | //flip h | ||
| 8535 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 8536 | //return an error, cannot both rotate and flip H | ||
| 8537 | ✗ | break; | |
| 8538 | |||
| 8539 | case 9: | ||
| 8540 | //trans + h flip | ||
| 8541 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 8542 | //return an error, cannot rotate and flip a trans sprite | ||
| 8543 | ✗ | break; | |
| 8544 | |||
| 8545 | case 10: | ||
| 8546 | //flip H and pivot | ||
| 8547 | //return error cannot pivot and h flip | ||
| 8548 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 8549 | ✗ | break; | |
| 8550 | |||
| 8551 | case 12: | ||
| 8552 | //vh flip | ||
| 8553 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8554 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8555 | ✗ | break; | |
| 8556 | |||
| 8557 | case 13: | ||
| 8558 | //trans + vh flip | ||
| 8559 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8560 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8561 | ✗ | break; | |
| 8562 | |||
| 8563 | case 14: | ||
| 8564 | //pivot and vh flip | ||
| 8565 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8566 | //return error cannot both pivot and vh flip | ||
| 8567 | ✗ | break; | |
| 8568 | |||
| 8569 | case 16: | ||
| 8570 | //lit | ||
| 8571 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8572 | ✗ | rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8573 | ✗ | break; | |
| 8574 | |||
| 8575 | case 18: | ||
| 8576 | //pivot, lit | ||
| 8577 | //return an error, cannot both rotate and pivot | ||
| 8578 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8579 | ✗ | break; | |
| 8580 | |||
| 8581 | case 20: | ||
| 8582 | //lit + vflip | ||
| 8583 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8584 | ✗ | rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8585 | ✗ | break; | |
| 8586 | |||
| 8587 | case 22: | ||
| 8588 | //Pivot, vflip, lit | ||
| 8589 | //return an error, cannot both rotate and pivot | ||
| 8590 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8591 | ✗ | break; | |
| 8592 | |||
| 8593 | case 24: | ||
| 8594 | //lit + h flip | ||
| 8595 | //return an error, cannot both rotate and H flip | ||
| 8596 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 8597 | ✗ | break; | |
| 8598 | |||
| 8599 | case 26: | ||
| 8600 | //pivot + lit + hflip | ||
| 8601 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 8602 | //return error cannot pivot, lit, and flip | ||
| 8603 | ✗ | break; | |
| 8604 | |||
| 8605 | case 28: | ||
| 8606 | //lit + vh flip | ||
| 8607 | //return an error, cannot both rotate and VH flip | ||
| 8608 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8609 | ✗ | break; | |
| 8610 | |||
| 8611 | case 32: //gouraud | ||
| 8612 | //Probably not wort supporting. | ||
| 8613 | //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 8614 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 8615 | ✗ | break; | |
| 8616 | |||
| 8617 | case 0: | ||
| 8618 | //no effect. | ||
| 8619 | ✗ | masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8620 | ✗ | rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8621 | ✗ | break; | |
| 8622 | |||
| 8623 | default: | ||
| 8624 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 8625 | |||
| 8626 | } | ||
| 8627 | } | ||
| 8628 | } //end if stretched and masked | ||
| 8629 | |||
| 8630 | else //stretched, not masked | ||
| 8631 | { | ||
| 8632 | |||
| 8633 | |||
| 8634 | ✗ | if ( rot == 0 ) //if not rotated | |
| 8635 | { | ||
| 8636 | ✗ | switch(mode) | |
| 8637 | { | ||
| 8638 | case 1: | ||
| 8639 | //transparent | ||
| 8640 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8641 | ✗ | draw_trans_sprite(newDest, subBmp, dx, dy); | |
| 8642 | ✗ | break; | |
| 8643 | |||
| 8644 | |||
| 8645 | case 2: | ||
| 8646 | //pivot? | ||
| 8647 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8648 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8649 | //Pivoting requires two more args | ||
| 8650 | ✗ | break; | |
| 8651 | |||
| 8652 | case 3: | ||
| 8653 | //pivot + trans | ||
| 8654 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8655 | ✗ | pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot)); | |
| 8656 | ✗ | break; | |
| 8657 | |||
| 8658 | case 4: | ||
| 8659 | //flip v | ||
| 8660 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8661 | ✗ | draw_sprite_v_flip(newDest, subBmp, dx, dy); | |
| 8662 | ✗ | break; | |
| 8663 | |||
| 8664 | case 5: | ||
| 8665 | //trans + v flip | ||
| 8666 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8667 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 8668 | ✗ | break; | |
| 8669 | |||
| 8670 | case 6: | ||
| 8671 | //pivot + v flip | ||
| 8672 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8673 | ✗ | pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8674 | ✗ | break; | |
| 8675 | |||
| 8676 | case 8: | ||
| 8677 | //vlip h | ||
| 8678 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8679 | ✗ | draw_sprite_h_flip(newDest, subBmp, dx, dy); | |
| 8680 | ✗ | break; | |
| 8681 | |||
| 8682 | case 9: | ||
| 8683 | //trans + h flip | ||
| 8684 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8685 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 8686 | ✗ | break; | |
| 8687 | |||
| 8688 | case 10: | ||
| 8689 | //flip H and pivot | ||
| 8690 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 8691 | //return error cannot pivot and h flip | ||
| 8692 | ✗ | break; | |
| 8693 | |||
| 8694 | case 12: | ||
| 8695 | //vh flip | ||
| 8696 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8697 | ✗ | draw_sprite_vh_flip(newDest, subBmp, dx, dy); | |
| 8698 | ✗ | break; | |
| 8699 | |||
| 8700 | case 13: | ||
| 8701 | //trans + vh flip | ||
| 8702 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8703 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 8704 | ✗ | break; | |
| 8705 | |||
| 8706 | case 14: | ||
| 8707 | //pivot and vh flip | ||
| 8708 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8709 | //return error cannot both pivot and vh flip | ||
| 8710 | ✗ | break; | |
| 8711 | |||
| 8712 | case 16: | ||
| 8713 | //lit | ||
| 8714 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8715 | ✗ | draw_lit_sprite(newDest, subBmp, dx, dy, litcolour); | |
| 8716 | ✗ | break; | |
| 8717 | |||
| 8718 | case 18: | ||
| 8719 | //pivot, lit | ||
| 8720 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8721 | ✗ | pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 8722 | ✗ | break; | |
| 8723 | |||
| 8724 | case 20: | ||
| 8725 | //lit + v flip | ||
| 8726 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8727 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 8728 | ✗ | break; | |
| 8729 | |||
| 8730 | case 22: | ||
| 8731 | //Pivot, vflip, lit | ||
| 8732 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8733 | ✗ | pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 8734 | ✗ | break; | |
| 8735 | |||
| 8736 | case 24: | ||
| 8737 | //lit + h flip | ||
| 8738 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8739 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 8740 | ✗ | break; | |
| 8741 | |||
| 8742 | case 26: | ||
| 8743 | //pivot + lit + hflip | ||
| 8744 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 8745 | //return error cannot pivot, lit, and flip | ||
| 8746 | ✗ | break; | |
| 8747 | |||
| 8748 | case 28: | ||
| 8749 | //lit + vh flip | ||
| 8750 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8751 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 8752 | ✗ | break; | |
| 8753 | |||
| 8754 | case 32: //gouraud | ||
| 8755 | //Probably not wort supporting. | ||
| 8756 | //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 8757 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 8758 | ✗ | break; | |
| 8759 | |||
| 8760 | case 0: | ||
| 8761 | //no effect | ||
| 8762 | ✗ | stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh); | |
| 8763 | ✗ | break; | |
| 8764 | |||
| 8765 | |||
| 8766 | default: | ||
| 8767 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 8768 | |||
| 8769 | |||
| 8770 | } | ||
| 8771 | } //end if not rotated | ||
| 8772 | |||
| 8773 | ✗ | if ( rot != 0 ) //if rotated | |
| 8774 | { | ||
| 8775 | ✗ | switch(mode) | |
| 8776 | { | ||
| 8777 | case 1: | ||
| 8778 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 8779 | ✗ | rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8780 | |||
| 8781 | ✗ | break; | |
| 8782 | |||
| 8783 | case 2: | ||
| 8784 | //pivot? | ||
| 8785 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8786 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8787 | //Pivoting requires two more args | ||
| 8788 | ✗ | break; | |
| 8789 | |||
| 8790 | case 3: | ||
| 8791 | //pivot + trans | ||
| 8792 | //return an error, cannot both rotate and pivot | ||
| 8793 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8794 | ✗ | break; | |
| 8795 | |||
| 8796 | case 4: | ||
| 8797 | //flip v | ||
| 8798 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8799 | ✗ | rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8800 | ✗ | break; | |
| 8801 | |||
| 8802 | case 5: | ||
| 8803 | //trans + v flip | ||
| 8804 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8805 | ✗ | rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8806 | ✗ | break; | |
| 8807 | |||
| 8808 | case 6: | ||
| 8809 | //pivot + v flip | ||
| 8810 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8811 | //return an error, cannot both rotate and pivot | ||
| 8812 | ✗ | break; | |
| 8813 | |||
| 8814 | case 8: | ||
| 8815 | //flip h | ||
| 8816 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 8817 | //return an error, cannot both rotate and flip H | ||
| 8818 | ✗ | break; | |
| 8819 | |||
| 8820 | case 9: | ||
| 8821 | //trans + h flip | ||
| 8822 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 8823 | //return an error, cannot rotate and flip a trans sprite | ||
| 8824 | ✗ | break; | |
| 8825 | |||
| 8826 | case 10: | ||
| 8827 | //flip H and pivot | ||
| 8828 | //return error cannot pivot and h flip | ||
| 8829 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 8830 | ✗ | break; | |
| 8831 | |||
| 8832 | case 12: | ||
| 8833 | //vh flip | ||
| 8834 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8835 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8836 | ✗ | break; | |
| 8837 | |||
| 8838 | case 13: | ||
| 8839 | //trans + vh flip | ||
| 8840 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 8841 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 8842 | ✗ | break; | |
| 8843 | |||
| 8844 | case 14: | ||
| 8845 | //pivot and vh flip | ||
| 8846 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8847 | //return error cannot both pivot and vh flip | ||
| 8848 | ✗ | break; | |
| 8849 | |||
| 8850 | case 16: | ||
| 8851 | //lit | ||
| 8852 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 8853 | ✗ | rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8854 | ✗ | break; | |
| 8855 | |||
| 8856 | case 18: | ||
| 8857 | //pivot, lit | ||
| 8858 | //return an error, cannot both rotate and pivot | ||
| 8859 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 8860 | ✗ | break; | |
| 8861 | |||
| 8862 | case 20: | ||
| 8863 | //lit + vflip | ||
| 8864 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent | |
| 8865 | ✗ | rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 8866 | ✗ | break; | |
| 8867 | |||
| 8868 | case 22: | ||
| 8869 | //Pivot, vflip, lit | ||
| 8870 | //return an error, cannot both rotate and pivot | ||
| 8871 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 8872 | ✗ | break; | |
| 8873 | |||
| 8874 | case 24: | ||
| 8875 | //lit + h flip | ||
| 8876 | //return an error, cannot both rotate and H flip | ||
| 8877 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 8878 | ✗ | break; | |
| 8879 | |||
| 8880 | case 26: | ||
| 8881 | //pivot + lit + hflip | ||
| 8882 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 8883 | //return error cannot pivot, lit, and flip | ||
| 8884 | ✗ | break; | |
| 8885 | |||
| 8886 | case 28: | ||
| 8887 | //lit + vh flip | ||
| 8888 | //return an error, cannot both rotate and VH flip | ||
| 8889 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8890 | ✗ | break; | |
| 8891 | |||
| 8892 | case 32: //gouraud | ||
| 8893 | //Probably not wort supporting. | ||
| 8894 | //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 8895 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 8896 | ✗ | break; | |
| 8897 | |||
| 8898 | case 0: | ||
| 8899 | //no effect. | ||
| 8900 | ✗ | stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | |
| 8901 | ✗ | rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 8902 | ✗ | break; | |
| 8903 | |||
| 8904 | default: | ||
| 8905 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 8906 | |||
| 8907 | } | ||
| 8908 | } | ||
| 8909 | |||
| 8910 | } //end if stretched, but not masked | ||
| 8911 | } | ||
| 8912 | else //not stretched | ||
| 8913 | { | ||
| 8914 | |||
| 8915 | ✗ | if(masked) //if masked, but not stretched | |
| 8916 | { | ||
| 8917 | |||
| 8918 | ✗ | if ( rot == 0 ) //if not rotated | |
| 8919 | { | ||
| 8920 | ✗ | switch(mode) | |
| 8921 | { | ||
| 8922 | case 1: | ||
| 8923 | //transparent | ||
| 8924 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8925 | ✗ | draw_trans_sprite(newDest, subBmp, dx, dy); | |
| 8926 | ✗ | break; | |
| 8927 | |||
| 8928 | |||
| 8929 | case 2: | ||
| 8930 | //pivot? | ||
| 8931 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8932 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8933 | //Pivoting requires two more args | ||
| 8934 | ✗ | break; | |
| 8935 | |||
| 8936 | case 3: | ||
| 8937 | //pivot + trans | ||
| 8938 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8939 | ✗ | pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8940 | ✗ | break; | |
| 8941 | |||
| 8942 | case 4: | ||
| 8943 | //flip v | ||
| 8944 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8945 | ✗ | draw_sprite_v_flip(newDest, subBmp, dx, dy); | |
| 8946 | ✗ | break; | |
| 8947 | |||
| 8948 | case 5: | ||
| 8949 | //trans + v flip | ||
| 8950 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8951 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 8952 | ✗ | break; | |
| 8953 | |||
| 8954 | case 6: | ||
| 8955 | //pivot + v flip | ||
| 8956 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8957 | ✗ | pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 8958 | ✗ | break; | |
| 8959 | |||
| 8960 | case 8: | ||
| 8961 | //vlip h | ||
| 8962 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8963 | ✗ | draw_sprite_h_flip(newDest, subBmp, dx, dy); | |
| 8964 | ✗ | break; | |
| 8965 | |||
| 8966 | case 9: | ||
| 8967 | //trans + h flip | ||
| 8968 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8969 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 8970 | ✗ | break; | |
| 8971 | |||
| 8972 | case 10: | ||
| 8973 | //flip H and pivot | ||
| 8974 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 8975 | //return error cannot pivot and h flip | ||
| 8976 | ✗ | break; | |
| 8977 | |||
| 8978 | case 12: | ||
| 8979 | //vh flip | ||
| 8980 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8981 | ✗ | draw_sprite_vh_flip(newDest, subBmp, dx, dy); | |
| 8982 | ✗ | break; | |
| 8983 | |||
| 8984 | case 13: | ||
| 8985 | //trans + vh flip | ||
| 8986 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8987 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 8988 | ✗ | break; | |
| 8989 | |||
| 8990 | case 14: | ||
| 8991 | //pivot and vh flip | ||
| 8992 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 8993 | //return error cannot both pivot and vh flip | ||
| 8994 | ✗ | break; | |
| 8995 | |||
| 8996 | case 16: | ||
| 8997 | //lit | ||
| 8998 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 8999 | ✗ | draw_lit_sprite(newDest, subBmp, dx, dy, litcolour); | |
| 9000 | ✗ | break; | |
| 9001 | |||
| 9002 | case 18: | ||
| 9003 | //pivot, lit | ||
| 9004 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9005 | ✗ | pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 9006 | ✗ | break; | |
| 9007 | |||
| 9008 | case 20: | ||
| 9009 | //lit + v flip | ||
| 9010 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9011 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 9012 | ✗ | break; | |
| 9013 | |||
| 9014 | case 22: | ||
| 9015 | //Pivot, vflip, lit | ||
| 9016 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9017 | ✗ | pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 9018 | ✗ | break; | |
| 9019 | |||
| 9020 | case 24: | ||
| 9021 | //lit + h flip | ||
| 9022 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9023 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 9024 | ✗ | break; | |
| 9025 | |||
| 9026 | case 26: | ||
| 9027 | //pivot + lit + hflip | ||
| 9028 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 9029 | //return error cannot pivot, lit, and flip | ||
| 9030 | ✗ | break; | |
| 9031 | |||
| 9032 | case 28: | ||
| 9033 | //lit + vh flip | ||
| 9034 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9035 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 9036 | ✗ | break; | |
| 9037 | |||
| 9038 | case 32: //gouraud | ||
| 9039 | //Probably not wort supporting. | ||
| 9040 | //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 9041 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 9042 | ✗ | break; | |
| 9043 | |||
| 9044 | case 0: | ||
| 9045 | //no effect | ||
| 9046 | ✗ | masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh); | |
| 9047 | ✗ | break; | |
| 9048 | |||
| 9049 | |||
| 9050 | default: | ||
| 9051 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 9052 | |||
| 9053 | |||
| 9054 | } | ||
| 9055 | } //end if not rotated | ||
| 9056 | |||
| 9057 | ✗ | if ( rot != 0 ) //if rotated | |
| 9058 | { | ||
| 9059 | ✗ | switch(mode) | |
| 9060 | { | ||
| 9061 | case 1: | ||
| 9062 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent | |
| 9063 | ✗ | rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9064 | |||
| 9065 | ✗ | break; | |
| 9066 | |||
| 9067 | case 2: | ||
| 9068 | //pivot? | ||
| 9069 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9070 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 9071 | //Pivoting requires two more args | ||
| 9072 | ✗ | break; | |
| 9073 | |||
| 9074 | case 3: | ||
| 9075 | //pivot + trans | ||
| 9076 | //return an error, cannot both rotate and pivot | ||
| 9077 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9078 | ✗ | break; | |
| 9079 | |||
| 9080 | case 4: | ||
| 9081 | //flip v | ||
| 9082 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9083 | ✗ | rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9084 | ✗ | break; | |
| 9085 | |||
| 9086 | case 5: | ||
| 9087 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip | |
| 9088 | ✗ | rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9089 | ✗ | break; | |
| 9090 | |||
| 9091 | case 6: | ||
| 9092 | //pivot + v flip | ||
| 9093 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9094 | //return an error, cannot both rotate and pivot | ||
| 9095 | ✗ | break; | |
| 9096 | |||
| 9097 | case 8: | ||
| 9098 | //flip h | ||
| 9099 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 9100 | //return an error, cannot both rotate and flip H | ||
| 9101 | ✗ | break; | |
| 9102 | |||
| 9103 | case 9: | ||
| 9104 | //trans + h flip | ||
| 9105 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 9106 | //return an error, cannot rotate and flip a trans sprite | ||
| 9107 | ✗ | break; | |
| 9108 | |||
| 9109 | case 10: | ||
| 9110 | //flip H and pivot | ||
| 9111 | //return error cannot pivot and h flip | ||
| 9112 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 9113 | ✗ | break; | |
| 9114 | |||
| 9115 | case 12: | ||
| 9116 | //vh flip | ||
| 9117 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 9118 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 9119 | ✗ | break; | |
| 9120 | |||
| 9121 | case 13: | ||
| 9122 | //trans + vh flip | ||
| 9123 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 9124 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 9125 | ✗ | break; | |
| 9126 | |||
| 9127 | case 14: | ||
| 9128 | //pivot and vh flip | ||
| 9129 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 9130 | //return error cannot both pivot and vh flip | ||
| 9131 | ✗ | break; | |
| 9132 | |||
| 9133 | case 16: | ||
| 9134 | //lit | ||
| 9135 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9136 | ✗ | rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 9137 | ✗ | break; | |
| 9138 | |||
| 9139 | case 18: | ||
| 9140 | //pivot, lit | ||
| 9141 | //return an error, cannot both rotate and pivot | ||
| 9142 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9143 | ✗ | break; | |
| 9144 | |||
| 9145 | case 20: | ||
| 9146 | //lit + vflip | ||
| 9147 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9148 | ✗ | rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 9149 | ✗ | break; | |
| 9150 | |||
| 9151 | case 22: | ||
| 9152 | //Pivot, vflip, lit | ||
| 9153 | //return an error, cannot both rotate and pivot | ||
| 9154 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 9155 | ✗ | break; | |
| 9156 | |||
| 9157 | case 24: | ||
| 9158 | //lit + h flip | ||
| 9159 | //return an error, cannot both rotate and H flip | ||
| 9160 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 9161 | ✗ | break; | |
| 9162 | |||
| 9163 | case 26: | ||
| 9164 | //pivot + lit + hflip | ||
| 9165 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 9166 | //return error cannot pivot, lit, and flip | ||
| 9167 | ✗ | break; | |
| 9168 | |||
| 9169 | case 28: | ||
| 9170 | //lit + vh flip | ||
| 9171 | //return an error, cannot both rotate and VH flip | ||
| 9172 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 9173 | ✗ | break; | |
| 9174 | |||
| 9175 | case 32: //gouraud | ||
| 9176 | //Probably not wort supporting. | ||
| 9177 | //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh); | ||
| 9178 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 9179 | ✗ | break; | |
| 9180 | |||
| 9181 | case 0: | ||
| 9182 | //no effect. | ||
| 9183 | ✗ | masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9184 | ✗ | rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9185 | ✗ | break; | |
| 9186 | |||
| 9187 | default: | ||
| 9188 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 9189 | |||
| 9190 | } | ||
| 9191 | } //end rtated, masked | ||
| 9192 | } //end if masked | ||
| 9193 | |||
| 9194 | else //not masked, and not stretched; just blit | ||
| 9195 | { | ||
| 9196 | |||
| 9197 | ✗ | if ( rot == 0 ) //if not rotated | |
| 9198 | { | ||
| 9199 | ✗ | switch(mode) | |
| 9200 | { | ||
| 9201 | case 1: | ||
| 9202 | //transparent | ||
| 9203 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9204 | ✗ | draw_trans_sprite(newDest, subBmp, dx, dy); | |
| 9205 | ✗ | break; | |
| 9206 | |||
| 9207 | |||
| 9208 | case 2: | ||
| 9209 | //pivot? | ||
| 9210 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9211 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 9212 | //Pivoting requires two more args | ||
| 9213 | ✗ | break; | |
| 9214 | |||
| 9215 | case 3: | ||
| 9216 | //pivot + trans | ||
| 9217 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9218 | ✗ | pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 9219 | ✗ | break; | |
| 9220 | |||
| 9221 | case 4: | ||
| 9222 | //flip v | ||
| 9223 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9224 | ✗ | draw_sprite_v_flip(newDest, subBmp, dx, dy); | |
| 9225 | ✗ | break; | |
| 9226 | |||
| 9227 | case 5: | ||
| 9228 | //trans + v flip | ||
| 9229 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9230 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP); | |
| 9231 | ✗ | break; | |
| 9232 | |||
| 9233 | case 6: | ||
| 9234 | //pivot + v flip | ||
| 9235 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9236 | ✗ | pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 9237 | ✗ | break; | |
| 9238 | |||
| 9239 | case 8: | ||
| 9240 | //vlip h | ||
| 9241 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9242 | ✗ | draw_sprite_h_flip(newDest, subBmp, dx, dy); | |
| 9243 | ✗ | break; | |
| 9244 | |||
| 9245 | case 9: | ||
| 9246 | //trans + h flip | ||
| 9247 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9248 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP); | |
| 9249 | ✗ | break; | |
| 9250 | |||
| 9251 | case 10: | ||
| 9252 | //flip H and pivot | ||
| 9253 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 9254 | //return error cannot pivot and h flip | ||
| 9255 | ✗ | break; | |
| 9256 | |||
| 9257 | case 12: | ||
| 9258 | //vh flip | ||
| 9259 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9260 | ✗ | draw_sprite_vh_flip(newDest, subBmp, dx, dy); | |
| 9261 | ✗ | break; | |
| 9262 | |||
| 9263 | case 13: | ||
| 9264 | //trans + vh flip | ||
| 9265 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9266 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP); | |
| 9267 | ✗ | break; | |
| 9268 | |||
| 9269 | case 14: | ||
| 9270 | //pivot and vh flip | ||
| 9271 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 9272 | //return error cannot both pivot and vh flip | ||
| 9273 | ✗ | break; | |
| 9274 | |||
| 9275 | case 16: | ||
| 9276 | //lit | ||
| 9277 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9278 | ✗ | draw_lit_sprite(newDest, subBmp, dx, dy, litcolour); | |
| 9279 | ✗ | break; | |
| 9280 | |||
| 9281 | case 18: | ||
| 9282 | //pivot, lit | ||
| 9283 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9284 | ✗ | pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 9285 | ✗ | break; | |
| 9286 | |||
| 9287 | case 20: | ||
| 9288 | //lit + v flip | ||
| 9289 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9290 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP); | |
| 9291 | ✗ | break; | |
| 9292 | |||
| 9293 | case 22: | ||
| 9294 | //Pivot, vflip, lit | ||
| 9295 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9296 | ✗ | pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour); | |
| 9297 | ✗ | break; | |
| 9298 | |||
| 9299 | case 24: | ||
| 9300 | //lit + h flip | ||
| 9301 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9302 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP); | |
| 9303 | ✗ | break; | |
| 9304 | |||
| 9305 | case 26: | ||
| 9306 | //pivot + lit + hflip | ||
| 9307 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex); | |
| 9308 | //return error cannot pivot, lit, and flip | ||
| 9309 | ✗ | break; | |
| 9310 | |||
| 9311 | case 28: | ||
| 9312 | //lit + vh flip | ||
| 9313 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9314 | ✗ | draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP); | |
| 9315 | ✗ | break; | |
| 9316 | |||
| 9317 | case 32: //gouraud | ||
| 9318 | //Probably not wort supporting. | ||
| 9319 | //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 9320 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 9321 | ✗ | break; | |
| 9322 | |||
| 9323 | case 0: | ||
| 9324 | //no effect | ||
| 9325 | ✗ | blit(newSource, newDest, sx, sy, dx, dy, dw, dh); | |
| 9326 | ✗ | break; | |
| 9327 | |||
| 9328 | |||
| 9329 | default: | ||
| 9330 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 9331 | |||
| 9332 | |||
| 9333 | } | ||
| 9334 | } //end if not rotated | ||
| 9335 | |||
| 9336 | ✗ | if ( rot != 0 ) //if rotated | |
| 9337 | { | ||
| 9338 | ✗ | switch(mode) | |
| 9339 | { | ||
| 9340 | case 1: | ||
| 9341 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent | |
| 9342 | ✗ | rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9343 | |||
| 9344 | ✗ | break; | |
| 9345 | |||
| 9346 | case 2: | ||
| 9347 | //pivot? | ||
| 9348 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9349 | ✗ | pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot)); | |
| 9350 | //Pivoting requires two more args | ||
| 9351 | ✗ | break; | |
| 9352 | |||
| 9353 | case 3: | ||
| 9354 | //pivot + trans | ||
| 9355 | //return an error, cannot both rotate and pivot | ||
| 9356 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9357 | ✗ | break; | |
| 9358 | |||
| 9359 | case 4: | ||
| 9360 | //flip v | ||
| 9361 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9362 | ✗ | rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9363 | ✗ | break; | |
| 9364 | |||
| 9365 | case 5: | ||
| 9366 | //trans + v flip | ||
| 9367 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9368 | ✗ | rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9369 | ✗ | break; | |
| 9370 | |||
| 9371 | case 6: | ||
| 9372 | //pivot + v flip | ||
| 9373 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9374 | //return an error, cannot both rotate and pivot | ||
| 9375 | ✗ | break; | |
| 9376 | |||
| 9377 | case 8: | ||
| 9378 | //flip h | ||
| 9379 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex); | |
| 9380 | //return an error, cannot both rotate and flip H | ||
| 9381 | ✗ | break; | |
| 9382 | |||
| 9383 | case 9: | ||
| 9384 | //trans + h flip | ||
| 9385 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex); | |
| 9386 | //return an error, cannot rotate and flip a trans sprite | ||
| 9387 | ✗ | break; | |
| 9388 | |||
| 9389 | case 10: | ||
| 9390 | //flip H and pivot | ||
| 9391 | //return error cannot pivot and h flip | ||
| 9392 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex); | |
| 9393 | ✗ | break; | |
| 9394 | |||
| 9395 | case 12: | ||
| 9396 | //vh flip | ||
| 9397 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 9398 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 9399 | ✗ | break; | |
| 9400 | |||
| 9401 | case 13: | ||
| 9402 | //trans + vh flip | ||
| 9403 | //return an error, cannot rotate and VH flip a trans sprite | ||
| 9404 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex); | |
| 9405 | ✗ | break; | |
| 9406 | |||
| 9407 | case 14: | ||
| 9408 | //pivot and vh flip | ||
| 9409 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 9410 | //return error cannot both pivot and vh flip | ||
| 9411 | ✗ | break; | |
| 9412 | |||
| 9413 | case 16: | ||
| 9414 | //lit | ||
| 9415 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9416 | ✗ | rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 9417 | ✗ | break; | |
| 9418 | |||
| 9419 | case 18: | ||
| 9420 | //pivot, lit | ||
| 9421 | //return an error, cannot both rotate and pivot | ||
| 9422 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex); | |
| 9423 | ✗ | break; | |
| 9424 | |||
| 9425 | case 20: | ||
| 9426 | //lit + vflip | ||
| 9427 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9428 | ✗ | rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour); | |
| 9429 | ✗ | break; | |
| 9430 | |||
| 9431 | case 22: | ||
| 9432 | //Pivot, vflip, lit | ||
| 9433 | //return an error, cannot both rotate and pivot | ||
| 9434 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex); | |
| 9435 | ✗ | break; | |
| 9436 | |||
| 9437 | case 24: | ||
| 9438 | //lit + h flip | ||
| 9439 | //return an error, cannot both rotate and H flip | ||
| 9440 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex); | |
| 9441 | ✗ | break; | |
| 9442 | |||
| 9443 | case 26: | ||
| 9444 | //pivot + lit + hflip | ||
| 9445 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex); | |
| 9446 | //return error cannot pivot, lit, and flip | ||
| 9447 | ✗ | break; | |
| 9448 | |||
| 9449 | case 28: | ||
| 9450 | //lit + vh flip | ||
| 9451 | //return an error, cannot both rotate and VH flip | ||
| 9452 | ✗ | Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex); | |
| 9453 | ✗ | break; | |
| 9454 | |||
| 9455 | case 32: //gouraud | ||
| 9456 | //Probably not wort supporting. | ||
| 9457 | //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | ||
| 9458 | //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4); | ||
| 9459 | ✗ | break; | |
| 9460 | |||
| 9461 | case 0: | ||
| 9462 | //no effect. | ||
| 9463 | ✗ | blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); | |
| 9464 | ✗ | rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot)); | |
| 9465 | ✗ | break; | |
| 9466 | |||
| 9467 | default: | ||
| 9468 | ✗ | return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex); | |
| 9469 | |||
| 9470 | } | ||
| 9471 | } //end if rotated | ||
| 9472 | } //end if not masked | ||
| 9473 | } //end if not stretched | ||
| 9474 | |||
| 9475 | //cleanup | ||
| 9476 | ✗ | if(subBmp) | |
| 9477 | { | ||
| 9478 | //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap. | ||
| 9479 | ✗ | destroy_bitmap(subBmp); | |
| 9480 | } | ||
| 9481 | ✗ | if(newSource != destBMP) | |
| 9482 | { | ||
| 9483 | ✗ | destroy_bitmap(newSource); | |
| 9484 | } | ||
| 9485 | } | ||
| 9486 | |||
| 9487 | |||
| 9488 | ✗ | void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 9489 | { | ||
| 9490 | |||
| 9491 | //sdci[1]=layer | ||
| 9492 | //sdci[2]=pos[12] | ||
| 9493 | //sdci[3]=uv[8] | ||
| 9494 | //sdci[4]=color[4] | ||
| 9495 | //sdci[5]=size[2] | ||
| 9496 | //sdci[6]=flip | ||
| 9497 | //sdci[7]=tile/combo | ||
| 9498 | //sdci[8]=polytype | ||
| 9499 | //sdci[9] = other bitmap as texture | ||
| 9500 | //sdci[17] Bitmap Pointer | ||
| 9501 | ✗ | if ( sdci[17] <= 0 ) | |
| 9502 | { | ||
| 9503 | ✗ | Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 9504 | ✗ | return; | |
| 9505 | } | ||
| 9506 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9507 | ✗ | if ( refbmp == NULL ) return; | |
| 9508 | |||
| 9509 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 9510 | |||
| 9511 | ✗ | if(!v_ptr) | |
| 9512 | { | ||
| 9513 | ✗ | al_trace("Quad3d: Vector pointer is null! Internal error. \n"); | |
| 9514 | ✗ | return; | |
| 9515 | } | ||
| 9516 | |||
| 9517 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 9518 | |||
| 9519 | ✗ | if(v.empty()) | |
| 9520 | ✗ | return; | |
| 9521 | |||
| 9522 | ✗ | int32_t* pos = &v[0]; | |
| 9523 | ✗ | int32_t* uv = &v[12]; | |
| 9524 | ✗ | int32_t* col = &v[20]; | |
| 9525 | ✗ | int32_t* size = &v[24]; | |
| 9526 | |||
| 9527 | ✗ | int32_t w = size[0]; //magic numerical constants... yuck. | |
| 9528 | ✗ | int32_t h = size[1]; | |
| 9529 | ✗ | int32_t flip = (sdci[6]/10000)&3; | |
| 9530 | ✗ | int32_t tile = sdci[7]/10000; | |
| 9531 | ✗ | int32_t polytype = sdci[8]/10000; | |
| 9532 | ✗ | int32_t quad_render_source = sdci[9]-10; | |
| 9533 | ✗ | Z_scripterrlog("Quad3D texture is %d\n", quad_render_source); | |
| 9534 | |||
| 9535 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 9536 | |||
| 9537 | ✗ | int32_t tex_width = w*16; | |
| 9538 | ✗ | int32_t tex_height = h*16; | |
| 9539 | |||
| 9540 | ✗ | bool mustDestroyBmp = false; | |
| 9541 | ✗ | BITMAP *tex=NULL; | |
| 9542 | |||
| 9543 | |||
| 9544 | ✗ | bool tex_is_bitmap = ( sdci[9] != 0 ); | |
| 9545 | //Z_scripterrlog("sdci[9] is %d\n", quad_render_source); | ||
| 9546 | //Z_scripterrlog("sdci[17] is %d\n", sdci[17]-10); | ||
| 9547 | BITMAP *bmptexture; | ||
| 9548 | |||
| 9549 | ✗ | if ( tex_is_bitmap ) bmptexture = FFCore.GetScriptBitmap(quad_render_source); | |
| 9550 | |||
| 9551 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 9552 | |||
| 9553 | |||
| 9554 | ✗ | if ( !tex_is_bitmap ) | |
| 9555 | { | ||
| 9556 | ✗ | tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 9557 | |||
| 9558 | ✗ | if(!tex) | |
| 9559 | { | ||
| 9560 | ✗ | mustDestroyBmp = true; | |
| 9561 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 9562 | ✗ | clear_bitmap(tex); | |
| 9563 | } | ||
| 9564 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 9565 | { | ||
| 9566 | ✗ | Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 9567 | ✗ | return; //non power of two error | |
| 9568 | } | ||
| 9569 | ✗ | if(tile > 0) // TILE | |
| 9570 | { | ||
| 9571 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip); | |
| 9572 | } | ||
| 9573 | else // COMBO | ||
| 9574 | { | ||
| 9575 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 9576 | ✗ | const int32_t tiletodraw = combo_tile(c, 0, 0); | |
| 9577 | ✗ | flip = flip ^ c.flip; | |
| 9578 | |||
| 9579 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip); | |
| 9580 | } | ||
| 9581 | |||
| 9582 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 9583 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 9584 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 9585 | ✗ | V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] }; | |
| 9586 | |||
| 9587 | ✗ | quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4); | |
| 9588 | ✗ | if(mustDestroyBmp) | |
| 9589 | ✗ | destroy_bitmap(tex); | |
| 9590 | } | ||
| 9591 | else | ||
| 9592 | { | ||
| 9593 | |||
| 9594 | ✗ | if ( !bmptexture ) | |
| 9595 | { | ||
| 9596 | ✗ | Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()"); | |
| 9597 | ✗ | tex_is_bitmap = 0; | |
| 9598 | ✗ | return; | |
| 9599 | } | ||
| 9600 | ✗ | if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 9601 | ✗ | if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 9602 | ✗ | if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h); | |
| 9603 | ✗ | if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w); | |
| 9604 | |||
| 9605 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 9606 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 9607 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 9608 | ✗ | V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] }; | |
| 9609 | |||
| 9610 | ✗ | BITMAP *foo = create_bitmap_ex(8, 256, 176); | |
| 9611 | |||
| 9612 | //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4); | ||
| 9613 | ✗ | quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4); | |
| 9614 | ✗ | destroy_bitmap(foo); | |
| 9615 | |||
| 9616 | } | ||
| 9617 | |||
| 9618 | |||
| 9619 | |||
| 9620 | } | ||
| 9621 | |||
| 9622 | |||
| 9623 | |||
| 9624 | ✗ | void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset) | |
| 9625 | { | ||
| 9626 | //sdci[1]=layer | ||
| 9627 | //sdci[2]=pos[9] | ||
| 9628 | //sdci[3]=uv[6] | ||
| 9629 | //sdci[4]=color[3] | ||
| 9630 | //sdci[5]=size[2] | ||
| 9631 | //sdci[6]=flip | ||
| 9632 | //sdci[7]=tile/combo | ||
| 9633 | //sdci[8]=polytype | ||
| 9634 | //sdci[9] bitmap as texture | ||
| 9635 | //sdci[17] Bitmap Pointer | ||
| 9636 | ✗ | if ( sdci[17] <= 0 ) | |
| 9637 | { | ||
| 9638 | ✗ | Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[17]); | |
| 9639 | ✗ | return; | |
| 9640 | } | ||
| 9641 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9642 | ✗ | if ( refbmp == NULL ) return; | |
| 9643 | |||
| 9644 | ✗ | std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr(); | |
| 9645 | |||
| 9646 | ✗ | if(!v_ptr) | |
| 9647 | { | ||
| 9648 | ✗ | al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n"); | |
| 9649 | ✗ | return; | |
| 9650 | } | ||
| 9651 | |||
| 9652 | ✗ | std::vector<int32_t> &v = *v_ptr; | |
| 9653 | |||
| 9654 | ✗ | if(v.empty()) | |
| 9655 | ✗ | return; | |
| 9656 | |||
| 9657 | ✗ | int32_t* pos = &v[0]; | |
| 9658 | ✗ | int32_t* uv = &v[9]; | |
| 9659 | ✗ | int32_t* col = &v[15]; | |
| 9660 | ✗ | int32_t* size = &v[18]; | |
| 9661 | |||
| 9662 | ✗ | int32_t w = size[0]; //magic numerical constants... yuck. | |
| 9663 | ✗ | int32_t h = size[1]; | |
| 9664 | ✗ | int32_t flip = (sdci[6]/10000)&3; | |
| 9665 | ✗ | int32_t tile = sdci[7]/10000; | |
| 9666 | ✗ | int32_t polytype = sdci[8]/10000; | |
| 9667 | ✗ | int32_t quad_render_source = sdci[9]-10; | |
| 9668 | ✗ | polytype = vbound(polytype, 0, 14); | |
| 9669 | |||
| 9670 | ✗ | if(((w-1) & w) != 0 || ((h-1) & h) != 0) | |
| 9671 | { | ||
| 9672 | ✗ | Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h); | |
| 9673 | ✗ | return; //non power of two error | |
| 9674 | } | ||
| 9675 | |||
| 9676 | ✗ | int32_t tex_width = w*16; | |
| 9677 | ✗ | int32_t tex_height = h*16; | |
| 9678 | |||
| 9679 | ✗ | bool mustDestroyBmp = false; | |
| 9680 | ✗ | BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h); | |
| 9681 | |||
| 9682 | ✗ | if(!tex) | |
| 9683 | { | ||
| 9684 | ✗ | mustDestroyBmp = true; | |
| 9685 | ✗ | tex = create_bitmap_ex(8, tex_width, tex_height); | |
| 9686 | ✗ | clear_bitmap(tex); | |
| 9687 | } | ||
| 9688 | |||
| 9689 | ✗ | bool tex_is_bitmap = ( sdci[9] != 0 ); | |
| 9690 | ✗ | BITMAP *bmptexture=NULL; | |
| 9691 | ✗ | if ( tex_is_bitmap ) | |
| 9692 | { | ||
| 9693 | ✗ | bmptexture = FFCore.GetScriptBitmap(quad_render_source); | |
| 9694 | ✗ | if ( !bmptexture ) | |
| 9695 | { | ||
| 9696 | ✗ | Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()"); | |
| 9697 | ✗ | tex_is_bitmap = 0; | |
| 9698 | } | ||
| 9699 | } | ||
| 9700 | |||
| 9701 | ✗ | if ( !tex_is_bitmap ) | |
| 9702 | { | ||
| 9703 | ✗ | if(tile > 0) // TILE | |
| 9704 | { | ||
| 9705 | ✗ | TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip); | |
| 9706 | } | ||
| 9707 | else // COMBO | ||
| 9708 | { | ||
| 9709 | ✗ | const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ]; | |
| 9710 | ✗ | const int32_t tiletodraw = combo_tile(c, 0, 0); | |
| 9711 | ✗ | flip = flip ^ c.flip; | |
| 9712 | |||
| 9713 | ✗ | TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip); | |
| 9714 | } | ||
| 9715 | |||
| 9716 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 9717 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 9718 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 9719 | |||
| 9720 | ✗ | triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3); | |
| 9721 | } | ||
| 9722 | else | ||
| 9723 | { | ||
| 9724 | ✗ | if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 9725 | ✗ | if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source); | |
| 9726 | ✗ | if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w); | |
| 9727 | ✗ | if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h); | |
| 9728 | |||
| 9729 | ✗ | V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] }; | |
| 9730 | ✗ | V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] }; | |
| 9731 | ✗ | V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] }; | |
| 9732 | |||
| 9733 | ✗ | triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3); | |
| 9734 | |||
| 9735 | |||
| 9736 | } | ||
| 9737 | ✗ | if(mustDestroyBmp) | |
| 9738 | ✗ | destroy_bitmap(tex); | |
| 9739 | |||
| 9740 | } | ||
| 9741 | |||
| 9742 | |||
| 9743 | ✗ | bool is_layer_transparent(const mapscr& m, int32_t layer) | |
| 9744 | { | ||
| 9745 | ✗ | layer = vbound(layer, 0, 5); | |
| 9746 | ✗ | return m.layeropacity[layer] == 128; | |
| 9747 | } | ||
| 9748 | |||
| 9749 | ✗ | mapscr *getmapscreen(int32_t map_index, int32_t screen_index, int32_t layer) //returns NULL for invalid or non-existent layer | |
| 9750 | { | ||
| 9751 | mapscr *base_screen; | ||
| 9752 | ✗ | int32_t index = map_index*MAPSCRS+screen_index; | |
| 9753 | |||
| 9754 | ✗ | if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size()) | |
| 9755 | ✗ | return NULL; | |
| 9756 | |||
| 9757 | ✗ | if(layer != 0) | |
| 9758 | { | ||
| 9759 | ✗ | layer = layer - 1; | |
| 9760 | |||
| 9761 | ✗ | base_screen=&(TheMaps[index]); | |
| 9762 | |||
| 9763 | ✗ | if(base_screen->layermap[layer]==0) | |
| 9764 | ✗ | return NULL; | |
| 9765 | |||
| 9766 | ✗ | index=(base_screen->layermap[layer]-1)*MAPSCRS+base_screen->layerscreen[layer]; | |
| 9767 | |||
| 9768 | ✗ | if((uint32_t)index >= TheMaps.size()) // Might as well make sure | |
| 9769 | ✗ | return NULL; | |
| 9770 | } | ||
| 9771 | |||
| 9772 | ✗ | return &(TheMaps[index]); | |
| 9773 | } | ||
| 9774 | |||
| 9775 | ✗ | void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent) | |
| 9776 | { | ||
| 9777 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 9778 | { | ||
| 9779 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 9780 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 9781 | |||
| 9782 | //const newcombo & c = combobuf[ m.data[i] ]; | ||
| 9783 | /* | ||
| 9784 | newcombo c = combobuf[m.data[i]]; | ||
| 9785 | int32_t csets[4]; | ||
| 9786 | int32_t cofs = c.csets&15; | ||
| 9787 | |||
| 9788 | if(cofs&8) | ||
| 9789 | cofs |= ~int32_t(0xF); | ||
| 9790 | |||
| 9791 | for(int32_t i=0; i<4; ++i) | ||
| 9792 | csets[i] = c.csets&(16<<i) ? cset + cofs : cset; | ||
| 9793 | |||
| 9794 | |||
| 9795 | const int32_t tile = combo_tile(c, x2, y2); | ||
| 9796 | */ | ||
| 9797 | |||
| 9798 | ✗ | if(transparent) | |
| 9799 | { | ||
| 9800 | //void overcomboblocktranslucent(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h, int32_t opacity) | ||
| 9801 | ✗ | overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128); | |
| 9802 | //overtiletranslucent16(b, tile, x2, y2, m.cset[i], c.flip, 128); | ||
| 9803 | } | ||
| 9804 | else | ||
| 9805 | { | ||
| 9806 | //overcomboblock(BITMAP *dest, int32_t x, int32_t y, int32_t cmbdat, int32_t cset, int32_t w, int32_t h) | ||
| 9807 | ✗ | overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1); | |
| 9808 | //overtile16(b, tile, x2, y2, m.cset[i], c.flip); | ||
| 9809 | } | ||
| 9810 | } | ||
| 9811 | } | ||
| 9812 | |||
| 9813 | ✗ | void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y) | |
| 9814 | { | ||
| 9815 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 9816 | |||
| 9817 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 9818 | { | ||
| 9819 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 9820 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 9821 | //Blit the palette index of the solidity value. | ||
| 9822 | //int32_t col = (combobuf[m.data[i]].walk&15); | ||
| 9823 | //if ( col != 0 ) | ||
| 9824 | //{ | ||
| 9825 | // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col); | ||
| 9826 | // | ||
| 9827 | //} | ||
| 9828 | ✗ | clear_to_color(square,(combobuf[m.data[i]].walk&15)); | |
| 9829 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 9830 | ✗ | else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 9831 | } | ||
| 9832 | ✗ | destroy_bitmap(square); | |
| 9833 | } | ||
| 9834 | |||
| 9835 | ✗ | void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 9836 | { | ||
| 9837 | //sdci[1]=layer | ||
| 9838 | //sdci[2]=map | ||
| 9839 | //sdci[3]=screen | ||
| 9840 | //sdci[4]=x | ||
| 9841 | //sdci[5]=y | ||
| 9842 | //sdci[6]=rotation | ||
| 9843 | //sdci[17] Bitmap Pointer | ||
| 9844 | |||
| 9845 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9846 | ✗ | if ( refbmp == NULL ) return; | |
| 9847 | |||
| 9848 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 9849 | |||
| 9850 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 9851 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 9852 | ✗ | int32_t x = sdci[4]/10000; | |
| 9853 | ✗ | int32_t y = sdci[5]/10000; | |
| 9854 | ✗ | int32_t x1 = x + xoffset; | |
| 9855 | ✗ | int32_t y1 = y + yoffset; | |
| 9856 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 9857 | |||
| 9858 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 9859 | |||
| 9860 | ✗ | if(index >= TheMaps.size()) | |
| 9861 | { | ||
| 9862 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 9863 | ✗ | return; | |
| 9864 | } | ||
| 9865 | |||
| 9866 | ✗ | const mapscr & m = TheMaps[index]; | |
| 9867 | |||
| 9868 | |||
| 9869 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9870 | ✗ | if ( refbmp == NULL ) return; | |
| 9871 | |||
| 9872 | ✗ | if(rotation != 0) | |
| 9873 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 9874 | |||
| 9875 | //draw layer 0 | ||
| 9876 | ✗ | draw_map_solidity(b, m, x1, y1); | |
| 9877 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) | |
| 9878 | { | ||
| 9879 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 9880 | { | ||
| 9881 | ✗ | if(m.layermap[i] == 0) continue; | |
| 9882 | |||
| 9883 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 9884 | |||
| 9885 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 9886 | ✗ | continue; | |
| 9887 | |||
| 9888 | //draw valid layers | ||
| 9889 | ✗ | draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1); | |
| 9890 | } | ||
| 9891 | } | ||
| 9892 | |||
| 9893 | ✗ | if(rotation != 0) // rotate | |
| 9894 | { | ||
| 9895 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 9896 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 9897 | } | ||
| 9898 | } | ||
| 9899 | |||
| 9900 | ✗ | void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y) | |
| 9901 | { | ||
| 9902 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 9903 | ✗ | BITMAP* subsquare = create_bitmap_ex(8,16,16); | |
| 9904 | ✗ | clear_to_color(subsquare,1); | |
| 9905 | |||
| 9906 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 9907 | { | ||
| 9908 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 9909 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 9910 | //Blit the palette index of the solidity value. | ||
| 9911 | //int32_t col = (combobuf[m.data[i]].walk&15); | ||
| 9912 | //if ( col != 0 ) | ||
| 9913 | //{ | ||
| 9914 | // Z_scripterrlog("Position %d has a solidity value of %d.\n", i, col); | ||
| 9915 | // | ||
| 9916 | //} | ||
| 9917 | ✗ | clear_bitmap(square); | |
| 9918 | ✗ | int32_t sol = (combobuf[m.data[i]].walk); | |
| 9919 | //al_trace("Solidity is: %d.\n", sol); | ||
| 9920 | ✗ | if ( sol & 1 ) | |
| 9921 | { | ||
| 9922 | ✗ | blit(subsquare, square, 0, 0, 0, 0, 8, 8); | |
| 9923 | } | ||
| 9924 | ✗ | if ( sol & 2 ) | |
| 9925 | { | ||
| 9926 | ✗ | blit(subsquare, square, 0, 0, 0, 8, 8, 8); | |
| 9927 | } | ||
| 9928 | ✗ | if ( sol & 4 ) | |
| 9929 | { | ||
| 9930 | ✗ | blit(subsquare, square, 0, 0, 8, 0, 8, 8); | |
| 9931 | } | ||
| 9932 | ✗ | if ( sol &8 ) { | |
| 9933 | ✗ | blit(subsquare, square, 0, 0, 8, 8, 8, 8); | |
| 9934 | } | ||
| 9935 | |||
| 9936 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 9937 | ✗ | else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 9938 | } | ||
| 9939 | ✗ | destroy_bitmap(square); | |
| 9940 | ✗ | destroy_bitmap(subsquare); | |
| 9941 | } | ||
| 9942 | |||
| 9943 | ✗ | void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 9944 | { | ||
| 9945 | //sdci[1]=layer | ||
| 9946 | //sdci[2]=map | ||
| 9947 | //sdci[3]=screen | ||
| 9948 | //sdci[4]=x | ||
| 9949 | //sdci[5]=y | ||
| 9950 | //sdci[6]=rotation | ||
| 9951 | //sdci[17] Bitmap Pointer | ||
| 9952 | |||
| 9953 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9954 | ✗ | if ( refbmp == NULL ) return; | |
| 9955 | |||
| 9956 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 9957 | |||
| 9958 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 9959 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 9960 | ✗ | int32_t x = sdci[4]/10000; | |
| 9961 | ✗ | int32_t y = sdci[5]/10000; | |
| 9962 | ✗ | int32_t x1 = x + xoffset; | |
| 9963 | ✗ | int32_t y1 = y + yoffset; | |
| 9964 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 9965 | |||
| 9966 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 9967 | |||
| 9968 | ✗ | if(index >= TheMaps.size()) | |
| 9969 | { | ||
| 9970 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 9971 | ✗ | return; | |
| 9972 | } | ||
| 9973 | |||
| 9974 | ✗ | const mapscr & m = TheMaps[index]; | |
| 9975 | |||
| 9976 | |||
| 9977 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 9978 | ✗ | if ( refbmp == NULL ) return; | |
| 9979 | |||
| 9980 | ✗ | if(rotation != 0) | |
| 9981 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 9982 | |||
| 9983 | //draw layer 0 | ||
| 9984 | ✗ | draw_map_solid(b, m, x1, y1); | |
| 9985 | |||
| 9986 | ✗ | for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine. | |
| 9987 | { | ||
| 9988 | ✗ | if(m.layermap[i] == 0) continue; | |
| 9989 | |||
| 9990 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 9991 | |||
| 9992 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 9993 | ✗ | continue; | |
| 9994 | |||
| 9995 | //draw valid layers | ||
| 9996 | ✗ | draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1); | |
| 9997 | } | ||
| 9998 | |||
| 9999 | ✗ | if(rotation != 0) // rotate | |
| 10000 | { | ||
| 10001 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10002 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10003 | } | ||
| 10004 | } | ||
| 10005 | |||
| 10006 | ✗ | void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y) | |
| 10007 | { | ||
| 10008 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10009 | |||
| 10010 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10011 | { | ||
| 10012 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 10013 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 10014 | //Blit the palette index of the solidity value. | ||
| 10015 | ✗ | clear_to_color(square,m.sflag[i]); | |
| 10016 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10017 | ✗ | else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10018 | } | ||
| 10019 | ✗ | destroy_bitmap(square); | |
| 10020 | } | ||
| 10021 | |||
| 10022 | ✗ | void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10023 | { | ||
| 10024 | //sdci[1]=layer | ||
| 10025 | //sdci[2]=map | ||
| 10026 | //sdci[3]=screen | ||
| 10027 | //sdci[4]=x | ||
| 10028 | //sdci[5]=y | ||
| 10029 | //sdci[6]=rotation | ||
| 10030 | //sdci[17] Bitmap Pointer | ||
| 10031 | |||
| 10032 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10033 | ✗ | if ( refbmp == NULL ) return; | |
| 10034 | |||
| 10035 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 10036 | |||
| 10037 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10038 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10039 | ✗ | int32_t x = sdci[4]/10000; | |
| 10040 | ✗ | int32_t y = sdci[5]/10000; | |
| 10041 | ✗ | int32_t x1 = x + xoffset; | |
| 10042 | ✗ | int32_t y1 = y + yoffset; | |
| 10043 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 10044 | |||
| 10045 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10046 | |||
| 10047 | ✗ | if(index >= TheMaps.size()) | |
| 10048 | { | ||
| 10049 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 10050 | ✗ | return; | |
| 10051 | } | ||
| 10052 | |||
| 10053 | ✗ | const mapscr & m = TheMaps[index]; | |
| 10054 | |||
| 10055 | |||
| 10056 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10057 | ✗ | if ( refbmp == NULL ) return; | |
| 10058 | |||
| 10059 | ✗ | if(rotation != 0) | |
| 10060 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10061 | |||
| 10062 | //draw layer 0 | ||
| 10063 | ✗ | draw_map_cflag(b, m, x1, y1); | |
| 10064 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) | |
| 10065 | { | ||
| 10066 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 10067 | { | ||
| 10068 | ✗ | if(m.layermap[i] == 0) continue; | |
| 10069 | |||
| 10070 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 10071 | |||
| 10072 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 10073 | ✗ | continue; | |
| 10074 | |||
| 10075 | //draw valid layers | ||
| 10076 | ✗ | draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1); | |
| 10077 | } | ||
| 10078 | } | ||
| 10079 | |||
| 10080 | ✗ | if(rotation != 0) // rotate | |
| 10081 | { | ||
| 10082 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10083 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10084 | } | ||
| 10085 | } | ||
| 10086 | |||
| 10087 | |||
| 10088 | ✗ | void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y) | |
| 10089 | { | ||
| 10090 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10091 | |||
| 10092 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10093 | { | ||
| 10094 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 10095 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 10096 | //Blit the palette index of the solidity value. | ||
| 10097 | ✗ | clear_to_color(square,(combobuf[m.data[i]].type)); | |
| 10098 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10099 | ✗ | else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10100 | } | ||
| 10101 | ✗ | destroy_bitmap(square); | |
| 10102 | } | ||
| 10103 | |||
| 10104 | ✗ | void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10105 | { | ||
| 10106 | //sdci[1]=layer | ||
| 10107 | //sdci[2]=map | ||
| 10108 | //sdci[3]=screen | ||
| 10109 | //sdci[4]=x | ||
| 10110 | //sdci[5]=y | ||
| 10111 | //sdci[6]=rotation | ||
| 10112 | //sdci[17] Bitmap Pointer | ||
| 10113 | |||
| 10114 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10115 | ✗ | if ( refbmp == NULL ) return; | |
| 10116 | |||
| 10117 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 10118 | |||
| 10119 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10120 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10121 | ✗ | int32_t x = sdci[4]/10000; | |
| 10122 | ✗ | int32_t y = sdci[5]/10000; | |
| 10123 | ✗ | int32_t x1 = x + xoffset; | |
| 10124 | ✗ | int32_t y1 = y + yoffset; | |
| 10125 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 10126 | |||
| 10127 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10128 | |||
| 10129 | ✗ | if(index >= TheMaps.size()) | |
| 10130 | { | ||
| 10131 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 10132 | ✗ | return; | |
| 10133 | } | ||
| 10134 | |||
| 10135 | ✗ | const mapscr & m = TheMaps[index]; | |
| 10136 | |||
| 10137 | |||
| 10138 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10139 | ✗ | if ( refbmp == NULL ) return; | |
| 10140 | |||
| 10141 | ✗ | if(rotation != 0) | |
| 10142 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10143 | |||
| 10144 | //draw layer 0 | ||
| 10145 | ✗ | draw_map_combotype(b, m, x1, y1); | |
| 10146 | |||
| 10147 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) | |
| 10148 | { | ||
| 10149 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 10150 | { | ||
| 10151 | ✗ | if(m.layermap[i] == 0) continue; | |
| 10152 | |||
| 10153 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 10154 | |||
| 10155 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 10156 | ✗ | continue; | |
| 10157 | |||
| 10158 | //draw valid layers | ||
| 10159 | ✗ | draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1); | |
| 10160 | } | ||
| 10161 | } | ||
| 10162 | |||
| 10163 | ✗ | if(rotation != 0) // rotate | |
| 10164 | { | ||
| 10165 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10166 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10167 | } | ||
| 10168 | } | ||
| 10169 | |||
| 10170 | |||
| 10171 | ✗ | void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y) | |
| 10172 | { | ||
| 10173 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10174 | |||
| 10175 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10176 | { | ||
| 10177 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 10178 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 10179 | //Blit the palette index of the solidity value. | ||
| 10180 | ✗ | clear_to_color(square,(combobuf[m.data[i]].flag)); | |
| 10181 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10182 | ✗ | else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10183 | } | ||
| 10184 | ✗ | destroy_bitmap(square); | |
| 10185 | } | ||
| 10186 | |||
| 10187 | ✗ | void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10188 | { | ||
| 10189 | //sdci[1]=layer | ||
| 10190 | //sdci[2]=map | ||
| 10191 | //sdci[3]=screen | ||
| 10192 | //sdci[4]=x | ||
| 10193 | //sdci[5]=y | ||
| 10194 | //sdci[6]=rotation | ||
| 10195 | //sdci[17] Bitmap Pointer | ||
| 10196 | |||
| 10197 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10198 | ✗ | if ( refbmp == NULL ) return; | |
| 10199 | |||
| 10200 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 10201 | |||
| 10202 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10203 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10204 | ✗ | int32_t x = sdci[4]/10000; | |
| 10205 | ✗ | int32_t y = sdci[5]/10000; | |
| 10206 | ✗ | int32_t x1 = x + xoffset; | |
| 10207 | ✗ | int32_t y1 = y + yoffset; | |
| 10208 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 10209 | |||
| 10210 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10211 | |||
| 10212 | ✗ | if(index >= TheMaps.size()) | |
| 10213 | { | ||
| 10214 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 10215 | ✗ | return; | |
| 10216 | } | ||
| 10217 | |||
| 10218 | ✗ | const mapscr & m = TheMaps[index]; | |
| 10219 | |||
| 10220 | |||
| 10221 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10222 | ✗ | if ( refbmp == NULL ) return; | |
| 10223 | |||
| 10224 | ✗ | if(rotation != 0) | |
| 10225 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10226 | |||
| 10227 | //draw layer 0 | ||
| 10228 | ✗ | draw_map_comboiflag(b, m, x1, y1); | |
| 10229 | |||
| 10230 | ✗ | if (get_bit(quest_rules, qr_BROKEN_DRAWSCREEN_FUNCTIONS)) | |
| 10231 | { | ||
| 10232 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 10233 | { | ||
| 10234 | ✗ | if(m.layermap[i] == 0) continue; | |
| 10235 | |||
| 10236 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 10237 | |||
| 10238 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 10239 | ✗ | continue; | |
| 10240 | |||
| 10241 | //draw valid layers | ||
| 10242 | ✗ | draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1); | |
| 10243 | } | ||
| 10244 | } | ||
| 10245 | |||
| 10246 | ✗ | if(rotation != 0) // rotate | |
| 10247 | { | ||
| 10248 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10249 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10250 | } | ||
| 10251 | } | ||
| 10252 | |||
| 10253 | ✗ | void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10254 | { | ||
| 10255 | //sdci[1]=layer | ||
| 10256 | //sdci[2]=map | ||
| 10257 | //sdci[3]=screen | ||
| 10258 | //sdci[4]=layer | ||
| 10259 | //sdci[5]=x | ||
| 10260 | //sdci[6]=y | ||
| 10261 | //sdci[7]=rotation | ||
| 10262 | //sdci[8]=opacity | ||
| 10263 | |||
| 10264 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10265 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10266 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10267 | ✗ | int32_t x = sdci[5]/10000; | |
| 10268 | ✗ | int32_t y = sdci[6]/10000; | |
| 10269 | ✗ | int32_t x1 = x + xoffset; | |
| 10270 | ✗ | int32_t y1 = y + yoffset; | |
| 10271 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10272 | ✗ | int32_t opacity = sdci[8]/10000; | |
| 10273 | |||
| 10274 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10275 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10276 | |||
| 10277 | ✗ | if(!m) //no need to log it. | |
| 10278 | ✗ | return; | |
| 10279 | |||
| 10280 | ✗ | if(index >= TheMaps.size()) | |
| 10281 | { | ||
| 10282 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10283 | ✗ | return; | |
| 10284 | } | ||
| 10285 | |||
| 10286 | ✗ | const mapscr & l = *m; | |
| 10287 | |||
| 10288 | ✗ | BITMAP* b = bmp; | |
| 10289 | |||
| 10290 | ✗ | if(rotation != 0) | |
| 10291 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10292 | |||
| 10293 | |||
| 10294 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10295 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10296 | ✗ | bool transparent = opacity <= 128; | |
| 10297 | |||
| 10298 | ✗ | if(rotation != 0) // rotate | |
| 10299 | { | ||
| 10300 | ✗ | draw_mapscr(b, l, x1, y1, transparent); | |
| 10301 | |||
| 10302 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10303 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10304 | } | ||
| 10305 | else | ||
| 10306 | { | ||
| 10307 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10308 | { | ||
| 10309 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10310 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10311 | |||
| 10312 | ✗ | if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect | |
| 10313 | { | ||
| 10314 | ✗ | const newcombo & c = combobuf[ l.data[i] ]; | |
| 10315 | ✗ | const int32_t tile = combo_tile(c, x2, y2); | |
| 10316 | |||
| 10317 | ✗ | if(opacity < 128) | |
| 10318 | { | ||
| 10319 | ✗ | overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128); | |
| 10320 | |||
| 10321 | |||
| 10322 | //overtiletranslucent16(b, tile, x2, y2, l.cset[i], c.flip, opacity); | ||
| 10323 | } | ||
| 10324 | else | ||
| 10325 | { | ||
| 10326 | ✗ | overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1); | |
| 10327 | //overtile16(b, tile, x2, y2, l.cset[i], c.flip); | ||
| 10328 | } | ||
| 10329 | //putcombo( b, xx, yy, l.data[i], l.cset[i] ); | ||
| 10330 | } | ||
| 10331 | } | ||
| 10332 | } | ||
| 10333 | |||
| 10334 | //putscr | ||
| 10335 | } | ||
| 10336 | |||
| 10337 | |||
| 10338 | |||
| 10339 | ✗ | void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10340 | { | ||
| 10341 | //sdci[1]=layer | ||
| 10342 | //sdci[2]=map | ||
| 10343 | //sdci[3]=screen | ||
| 10344 | //sdci[4]=x | ||
| 10345 | //sdci[5]=y | ||
| 10346 | //sdci[6]=rotation | ||
| 10347 | |||
| 10348 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10349 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10350 | ✗ | int32_t x = sdci[4]/10000; | |
| 10351 | ✗ | int32_t y = sdci[5]/10000; | |
| 10352 | ✗ | int32_t x1 = x + xoffset; | |
| 10353 | ✗ | int32_t y1 = y + yoffset; | |
| 10354 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 10355 | |||
| 10356 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10357 | |||
| 10358 | ✗ | if(index >= TheMaps.size()) | |
| 10359 | { | ||
| 10360 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 10361 | ✗ | return; | |
| 10362 | } | ||
| 10363 | |||
| 10364 | ✗ | const mapscr & m = TheMaps[index]; | |
| 10365 | |||
| 10366 | |||
| 10367 | ✗ | BITMAP* b = bmp; | |
| 10368 | |||
| 10369 | ✗ | if(rotation != 0) | |
| 10370 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10371 | |||
| 10372 | //draw layer 0 | ||
| 10373 | ✗ | draw_mapscr(b, m, x1, y1, false); | |
| 10374 | |||
| 10375 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 10376 | { | ||
| 10377 | ✗ | if(m.layermap[i] == 0) continue; | |
| 10378 | |||
| 10379 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 10380 | |||
| 10381 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 10382 | ✗ | continue; | |
| 10383 | |||
| 10384 | ✗ | bool trans = m.layeropacity[i] == 128; | |
| 10385 | |||
| 10386 | //draw valid layers | ||
| 10387 | ✗ | draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans); | |
| 10388 | } | ||
| 10389 | |||
| 10390 | ✗ | if(rotation != 0) // rotate | |
| 10391 | { | ||
| 10392 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10393 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10394 | } | ||
| 10395 | } | ||
| 10396 | |||
| 10397 | |||
| 10398 | ✗ | void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10399 | { | ||
| 10400 | //sdci[1]=layer | ||
| 10401 | //sdci[2]=map | ||
| 10402 | //sdci[3]=screen | ||
| 10403 | //sdci[4]=layer | ||
| 10404 | //sdci[5]=x | ||
| 10405 | //sdci[6]=y | ||
| 10406 | //sdci[7]=rotation | ||
| 10407 | //[8] noclip | ||
| 10408 | //sdci[9]=opacity | ||
| 10409 | //sdci[17] Bitmap Pointer | ||
| 10410 | |||
| 10411 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10412 | ✗ | if ( refbmp == NULL ) return; | |
| 10413 | |||
| 10414 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10415 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10416 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10417 | ✗ | int32_t x = sdci[5]/10000; | |
| 10418 | ✗ | int32_t y = sdci[6]/10000; | |
| 10419 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10420 | |||
| 10421 | ✗ | byte noclip = 0;//(sdci[8]!=0); | |
| 10422 | ✗ | int32_t opacity = sdci[8]/10000; | |
| 10423 | //zprint2("Running bmp->DrawLayer(%d, %d, %d, %d, %d, %d, %d, %d)\n", sdci[1]/10000, map, scrn, sourceLayer, x, y, rotation, opacity); | ||
| 10424 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10425 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10426 | |||
| 10427 | ✗ | if(!m) //no need to log it. | |
| 10428 | ✗ | return; | |
| 10429 | |||
| 10430 | ✗ | if(index >= TheMaps.size()) | |
| 10431 | { | ||
| 10432 | ✗ | Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %d.\n", index, TheMaps.size()); | |
| 10433 | ✗ | return; | |
| 10434 | } | ||
| 10435 | |||
| 10436 | ✗ | const mapscr & l = *m; | |
| 10437 | |||
| 10438 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10439 | ✗ | if ( refbmp == NULL ) return; | |
| 10440 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 10441 | ✗ | if(rotation != 0) | |
| 10442 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10443 | |||
| 10444 | |||
| 10445 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10446 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10447 | ✗ | bool transparent = opacity <= 128; | |
| 10448 | |||
| 10449 | ✗ | if(rotation != 0) // rotate | |
| 10450 | { | ||
| 10451 | ✗ | draw_mapscr(b, l, x, y, transparent); | |
| 10452 | |||
| 10453 | ✗ | rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation)); | |
| 10454 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10455 | } | ||
| 10456 | else | ||
| 10457 | { | ||
| 10458 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10459 | { | ||
| 10460 | ✗ | const int32_t x2 = ((i&15)<<4) + x; | |
| 10461 | ✗ | const int32_t y2 = (i&0xF0) + y; | |
| 10462 | |||
| 10463 | //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | ||
| 10464 | { | ||
| 10465 | ✗ | const newcombo & c = combobuf[ l.data[i] ]; | |
| 10466 | ✗ | const int32_t tile = combo_tile(c, x2, y2); | |
| 10467 | |||
| 10468 | ✗ | if(opacity < 128) | |
| 10469 | ✗ | overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity); | |
| 10470 | else | ||
| 10471 | ✗ | overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip); | |
| 10472 | |||
| 10473 | //putcombo( b, xx, yy, l.data[i], l.cset[i] ); | ||
| 10474 | } | ||
| 10475 | } | ||
| 10476 | } | ||
| 10477 | |||
| 10478 | //putscr | ||
| 10479 | } | ||
| 10480 | |||
| 10481 | |||
| 10482 | |||
| 10483 | ✗ | void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10484 | { | ||
| 10485 | //sdci[1]=layer | ||
| 10486 | //sdci[2]=map | ||
| 10487 | //sdci[3]=screen | ||
| 10488 | //sdci[4]=x | ||
| 10489 | //sdci[5]=y | ||
| 10490 | //sdci[6]=rotation | ||
| 10491 | //sdci[17] Bitmap Pointer | ||
| 10492 | |||
| 10493 | ✗ | BITMAP *refbmp = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10494 | ✗ | if ( refbmp == NULL ) return; | |
| 10495 | |||
| 10496 | ✗ | if ( (sdci[17]-10) != -2 && (sdci[17]-10) != -1 ) yoffset = 0; //Don't crop. | |
| 10497 | |||
| 10498 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10499 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10500 | ✗ | int32_t x = sdci[4]/10000; | |
| 10501 | ✗ | int32_t y = sdci[5]/10000; | |
| 10502 | ✗ | int32_t x1 = x + xoffset; | |
| 10503 | ✗ | int32_t y1 = y + yoffset; | |
| 10504 | ✗ | int32_t rotation = sdci[6]/10000; | |
| 10505 | |||
| 10506 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10507 | |||
| 10508 | ✗ | if(index >= TheMaps.size()) | |
| 10509 | { | ||
| 10510 | ✗ | al_trace("DrawScreen: invalid map or screen index. \n"); | |
| 10511 | ✗ | return; | |
| 10512 | } | ||
| 10513 | |||
| 10514 | ✗ | const mapscr & m = TheMaps[index]; | |
| 10515 | |||
| 10516 | |||
| 10517 | ✗ | BITMAP* b = FFCore.GetScriptBitmap(sdci[17]-10); | |
| 10518 | ✗ | if ( refbmp == NULL ) return; | |
| 10519 | |||
| 10520 | ✗ | if(rotation != 0) | |
| 10521 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10522 | |||
| 10523 | //draw layer 0 | ||
| 10524 | ✗ | draw_mapscr(b, m, x1, y1, false); | |
| 10525 | |||
| 10526 | ✗ | for(int32_t i(0); i < 6; ++i) | |
| 10527 | { | ||
| 10528 | ✗ | if(m.layermap[i] == 0) continue; | |
| 10529 | |||
| 10530 | ✗ | uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i]; | |
| 10531 | |||
| 10532 | ✗ | if(layer_screen_index >= TheMaps.size()) | |
| 10533 | ✗ | continue; | |
| 10534 | |||
| 10535 | ✗ | bool trans = m.layeropacity[i] == 128; | |
| 10536 | |||
| 10537 | //draw valid layers | ||
| 10538 | ✗ | draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans); | |
| 10539 | } | ||
| 10540 | |||
| 10541 | ✗ | if(rotation != 0) // rotate | |
| 10542 | { | ||
| 10543 | ✗ | rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10544 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10545 | } | ||
| 10546 | } | ||
| 10547 | |||
| 10548 | ✗ | void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10549 | { | ||
| 10550 | //sdci[1]=layer | ||
| 10551 | //sdci[2]=map | ||
| 10552 | //sdci[3]=screen | ||
| 10553 | //sdci[4]=layer | ||
| 10554 | //sdci[5]=x | ||
| 10555 | //sdci[6]=y | ||
| 10556 | //sdci[7]=rotation | ||
| 10557 | //sdci[8]=bool noclip | ||
| 10558 | //sdci[9] == opacity | ||
| 10559 | |||
| 10560 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10561 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10562 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10563 | ✗ | int32_t x = sdci[5]/10000; | |
| 10564 | ✗ | int32_t y = sdci[6]/10000; | |
| 10565 | ✗ | int32_t x1 = x + xoffset; | |
| 10566 | ✗ | int32_t y1 = y + yoffset; | |
| 10567 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10568 | ✗ | byte noclip = (sdci[8]!=0); | |
| 10569 | ✗ | int32_t opacity = sdci[9]/10000; | |
| 10570 | |||
| 10571 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10572 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10573 | |||
| 10574 | ✗ | if(!m) //no need to log it. | |
| 10575 | ✗ | return; | |
| 10576 | |||
| 10577 | ✗ | if(index >= TheMaps.size()) | |
| 10578 | { | ||
| 10579 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10580 | ✗ | return; | |
| 10581 | } | ||
| 10582 | |||
| 10583 | ✗ | const mapscr & l = *m; | |
| 10584 | |||
| 10585 | ✗ | BITMAP* b = bmp; | |
| 10586 | |||
| 10587 | ✗ | if(rotation != 0) | |
| 10588 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10589 | |||
| 10590 | |||
| 10591 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10592 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10593 | ✗ | bool transparent = opacity <= 128; | |
| 10594 | |||
| 10595 | ✗ | if(rotation != 0) // rotate | |
| 10596 | { | ||
| 10597 | ✗ | draw_map_solid(b, l, x1, y1); | |
| 10598 | |||
| 10599 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10600 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10601 | } | ||
| 10602 | else | ||
| 10603 | { | ||
| 10604 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10605 | ✗ | BITMAP* subsquare = create_bitmap_ex(8,16,16); | |
| 10606 | ✗ | clear_to_color(subsquare,1); | |
| 10607 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10608 | { | ||
| 10609 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10610 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10611 | |||
| 10612 | ✗ | if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | |
| 10613 | { | ||
| 10614 | ✗ | int32_t sol = (combobuf[l.data[i]].walk); | |
| 10615 | |||
| 10616 | ✗ | if ( sol & 1 ) | |
| 10617 | { | ||
| 10618 | ✗ | blit(subsquare, square, 0, 0, 0, 0, 8, 8); | |
| 10619 | } | ||
| 10620 | ✗ | if ( sol & 2 ) | |
| 10621 | { | ||
| 10622 | ✗ | blit(subsquare, square, 0, 0, 0, 8, 8, 8); | |
| 10623 | } | ||
| 10624 | ✗ | if ( sol & 4 ) | |
| 10625 | { | ||
| 10626 | ✗ | blit(subsquare, square, 0, 0, 8, 0, 8, 8); | |
| 10627 | } | ||
| 10628 | ✗ | if ( sol &8 ) { | |
| 10629 | ✗ | blit(subsquare, square, 0, 0, 8, 8, 8, 8); | |
| 10630 | } | ||
| 10631 | |||
| 10632 | ✗ | blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10633 | } | ||
| 10634 | } | ||
| 10635 | ✗ | destroy_bitmap(square); | |
| 10636 | ✗ | destroy_bitmap(subsquare); | |
| 10637 | } | ||
| 10638 | |||
| 10639 | //putscr | ||
| 10640 | } | ||
| 10641 | |||
| 10642 | ✗ | void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10643 | { | ||
| 10644 | //sdci[1]=layer | ||
| 10645 | //sdci[2]=map | ||
| 10646 | //sdci[3]=screen | ||
| 10647 | //sdci[4]=layer | ||
| 10648 | //sdci[5]=x | ||
| 10649 | //sdci[6]=y | ||
| 10650 | //sdci[7]=rotation | ||
| 10651 | //[8] noclip | ||
| 10652 | //sdci[9]=opacity | ||
| 10653 | |||
| 10654 | |||
| 10655 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10656 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10657 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10658 | ✗ | int32_t x = sdci[5]/10000; | |
| 10659 | ✗ | int32_t y = sdci[6]/10000; | |
| 10660 | ✗ | int32_t x1 = x + xoffset; | |
| 10661 | ✗ | int32_t y1 = y + yoffset; | |
| 10662 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10663 | ✗ | byte noclip = (sdci[8]!=0); | |
| 10664 | ✗ | int32_t opacity = sdci[9]/10000; | |
| 10665 | |||
| 10666 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10667 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10668 | |||
| 10669 | ✗ | if(!m) //no need to log it. | |
| 10670 | ✗ | return; | |
| 10671 | |||
| 10672 | ✗ | if(index >= TheMaps.size()) | |
| 10673 | { | ||
| 10674 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10675 | ✗ | return; | |
| 10676 | } | ||
| 10677 | |||
| 10678 | ✗ | const mapscr & l = *m; | |
| 10679 | |||
| 10680 | ✗ | BITMAP* b = bmp; | |
| 10681 | |||
| 10682 | ✗ | if(rotation != 0) | |
| 10683 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10684 | |||
| 10685 | |||
| 10686 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10687 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10688 | ✗ | bool transparent = opacity <= 128; | |
| 10689 | |||
| 10690 | ✗ | if(rotation != 0) // rotate | |
| 10691 | { | ||
| 10692 | ✗ | draw_map_solidity(b, l, x1, y1); | |
| 10693 | |||
| 10694 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10695 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10696 | } | ||
| 10697 | else | ||
| 10698 | { | ||
| 10699 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10700 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10701 | { | ||
| 10702 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10703 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10704 | |||
| 10705 | ✗ | if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | |
| 10706 | { | ||
| 10707 | ✗ | clear_to_color(square,(combobuf[l.data[i]].walk&15)); | |
| 10708 | ✗ | blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10709 | } | ||
| 10710 | } | ||
| 10711 | ✗ | destroy_bitmap(square); | |
| 10712 | } | ||
| 10713 | |||
| 10714 | //putscr | ||
| 10715 | } | ||
| 10716 | |||
| 10717 | ✗ | void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10718 | { | ||
| 10719 | //sdci[1]=layer | ||
| 10720 | //sdci[2]=map | ||
| 10721 | //sdci[3]=screen | ||
| 10722 | //sdci[4]=layer | ||
| 10723 | //sdci[5]=x | ||
| 10724 | //sdci[6]=y | ||
| 10725 | //sdci[7]=rotation | ||
| 10726 | //[8] noclip | ||
| 10727 | //sdci[9]=opacity | ||
| 10728 | |||
| 10729 | |||
| 10730 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10731 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10732 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10733 | ✗ | int32_t x = sdci[5]/10000; | |
| 10734 | ✗ | int32_t y = sdci[6]/10000; | |
| 10735 | ✗ | int32_t x1 = x + xoffset; | |
| 10736 | ✗ | int32_t y1 = y + yoffset; | |
| 10737 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10738 | |||
| 10739 | ✗ | byte noclip = (sdci[8]!=0); | |
| 10740 | ✗ | int32_t opacity = sdci[9]/10000; | |
| 10741 | |||
| 10742 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10743 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10744 | |||
| 10745 | ✗ | if(!m) //no need to log it. | |
| 10746 | ✗ | return; | |
| 10747 | |||
| 10748 | ✗ | if(index >= TheMaps.size()) | |
| 10749 | { | ||
| 10750 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10751 | ✗ | return; | |
| 10752 | } | ||
| 10753 | |||
| 10754 | ✗ | const mapscr & l = *m; | |
| 10755 | |||
| 10756 | ✗ | BITMAP* b = bmp; | |
| 10757 | |||
| 10758 | ✗ | if(rotation != 0) | |
| 10759 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10760 | |||
| 10761 | |||
| 10762 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10763 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10764 | ✗ | bool transparent = opacity <= 128; | |
| 10765 | |||
| 10766 | ✗ | if(rotation != 0) // rotate | |
| 10767 | { | ||
| 10768 | ✗ | draw_map_cflag(b, l, x1, y1); | |
| 10769 | |||
| 10770 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10771 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10772 | } | ||
| 10773 | else | ||
| 10774 | { | ||
| 10775 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10776 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10777 | { | ||
| 10778 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10779 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10780 | |||
| 10781 | ✗ | if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | |
| 10782 | { | ||
| 10783 | ✗ | clear_to_color(square,l.sflag[i]); | |
| 10784 | ✗ | blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10785 | } | ||
| 10786 | } | ||
| 10787 | ✗ | destroy_bitmap(square); | |
| 10788 | } | ||
| 10789 | |||
| 10790 | //putscr | ||
| 10791 | } | ||
| 10792 | |||
| 10793 | ✗ | void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10794 | { | ||
| 10795 | //sdci[1]=layer | ||
| 10796 | //sdci[2]=map | ||
| 10797 | //sdci[3]=screen | ||
| 10798 | //sdci[4]=layer | ||
| 10799 | //sdci[5]=x | ||
| 10800 | //sdci[6]=y | ||
| 10801 | //sdci[7]=rotation | ||
| 10802 | //[8] noclip | ||
| 10803 | //sdci[9]=opacity | ||
| 10804 | |||
| 10805 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10806 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10807 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10808 | ✗ | int32_t x = sdci[5]/10000; | |
| 10809 | ✗ | int32_t y = sdci[6]/10000; | |
| 10810 | ✗ | int32_t x1 = x + xoffset; | |
| 10811 | ✗ | int32_t y1 = y + yoffset; | |
| 10812 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10813 | |||
| 10814 | ✗ | byte noclip = (sdci[8]!=0); | |
| 10815 | ✗ | int32_t opacity = sdci[9]/10000; | |
| 10816 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10817 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10818 | |||
| 10819 | ✗ | if(!m) //no need to log it. | |
| 10820 | ✗ | return; | |
| 10821 | |||
| 10822 | ✗ | if(index >= TheMaps.size()) | |
| 10823 | { | ||
| 10824 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10825 | ✗ | return; | |
| 10826 | } | ||
| 10827 | |||
| 10828 | ✗ | const mapscr & l = *m; | |
| 10829 | |||
| 10830 | ✗ | BITMAP* b = bmp; | |
| 10831 | |||
| 10832 | ✗ | if(rotation != 0) | |
| 10833 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10834 | |||
| 10835 | |||
| 10836 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10837 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10838 | ✗ | bool transparent = opacity <= 128; | |
| 10839 | |||
| 10840 | ✗ | if(rotation != 0) // rotate | |
| 10841 | { | ||
| 10842 | ✗ | draw_map_combotype(b, l, x1, y1); | |
| 10843 | |||
| 10844 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10845 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10846 | } | ||
| 10847 | else | ||
| 10848 | { | ||
| 10849 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10850 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10851 | { | ||
| 10852 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10853 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10854 | |||
| 10855 | ✗ | if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | |
| 10856 | { | ||
| 10857 | ✗ | clear_to_color(square,(combobuf[l.data[i]].type)); | |
| 10858 | ✗ | blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10859 | } | ||
| 10860 | } | ||
| 10861 | ✗ | destroy_bitmap(square); | |
| 10862 | } | ||
| 10863 | |||
| 10864 | //putscr | ||
| 10865 | } | ||
| 10866 | |||
| 10867 | ✗ | void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen) | |
| 10868 | { | ||
| 10869 | //sdci[1]=layer | ||
| 10870 | //sdci[2]=map | ||
| 10871 | //sdci[3]=screen | ||
| 10872 | //sdci[4]=layer | ||
| 10873 | //sdci[5]=x | ||
| 10874 | //sdci[6]=y | ||
| 10875 | //sdci[7]=rotation | ||
| 10876 | //[8] noclip | ||
| 10877 | //sdci[9]=opacity | ||
| 10878 | |||
| 10879 | ✗ | int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1. | |
| 10880 | ✗ | int32_t scrn = sdci[3]/10000; | |
| 10881 | ✗ | int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6); | |
| 10882 | ✗ | int32_t x = sdci[5]/10000; | |
| 10883 | ✗ | int32_t y = sdci[6]/10000; | |
| 10884 | ✗ | int32_t x1 = x + xoffset; | |
| 10885 | ✗ | int32_t y1 = y + yoffset; | |
| 10886 | ✗ | int32_t rotation = sdci[7]/10000; | |
| 10887 | ✗ | byte noclip = (sdci[8]!=0); | |
| 10888 | ✗ | int32_t opacity = sdci[9]/10000; | |
| 10889 | |||
| 10890 | ✗ | const uint32_t index = (uint32_t)(map * MAPSCRS + scrn); | |
| 10891 | ✗ | const mapscr* m = getmapscreen(map, scrn, sourceLayer); | |
| 10892 | |||
| 10893 | ✗ | if(!m) //no need to log it. | |
| 10894 | ✗ | return; | |
| 10895 | |||
| 10896 | ✗ | if(index >= TheMaps.size()) | |
| 10897 | { | ||
| 10898 | ✗ | al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size()); | |
| 10899 | ✗ | return; | |
| 10900 | } | ||
| 10901 | |||
| 10902 | ✗ | const mapscr & l = *m; | |
| 10903 | |||
| 10904 | ✗ | BITMAP* b = bmp; | |
| 10905 | |||
| 10906 | ✗ | if(rotation != 0) | |
| 10907 | ✗ | b = script_drawing_commands.AquireSubBitmap(256, 176); | |
| 10908 | |||
| 10909 | |||
| 10910 | ✗ | const int32_t maxX = isOffScreen ? 512 : 256; | |
| 10911 | ✗ | const int32_t maxY = isOffScreen ? 512 : 176 + yoffset; | |
| 10912 | ✗ | bool transparent = opacity <= 128; | |
| 10913 | |||
| 10914 | ✗ | if(rotation != 0) // rotate | |
| 10915 | { | ||
| 10916 | ✗ | draw_map_comboiflag(b, l, x1, y1); | |
| 10917 | |||
| 10918 | ✗ | rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation)); | |
| 10919 | ✗ | script_drawing_commands.ReleaseSubBitmap(b); | |
| 10920 | } | ||
| 10921 | else | ||
| 10922 | { | ||
| 10923 | ✗ | BITMAP* square = create_bitmap_ex(8,16,16); | |
| 10924 | ✗ | for(int32_t i(0); i < 176; ++i) | |
| 10925 | { | ||
| 10926 | ✗ | const int32_t x2 = ((i&15)<<4) + x1; | |
| 10927 | ✗ | const int32_t y2 = (i&0xF0) + y1; | |
| 10928 | |||
| 10929 | ✗ | if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect | |
| 10930 | { | ||
| 10931 | ✗ | clear_to_color(square,(combobuf[l.data[i]].flag)); | |
| 10932 | ✗ | blit(square, b, 0, 0, x2, y2, square->w, square->h); | |
| 10933 | } | ||
| 10934 | } | ||
| 10935 | ✗ | destroy_bitmap(square); | |
| 10936 | } | ||
| 10937 | |||
| 10938 | //putscr | ||
| 10939 | } | ||
| 10940 | |||
| 10941 | |||
| 10942 | |||
| 10943 | ///////////////////////////////////////////////////////// | ||
| 10944 | // do primitives | ||
| 10945 | //////////////////////////////////////////////////////// | ||
| 10946 | |||
| 10947 | 6542704 | void do_primitives(BITMAP *targetBitmap, int32_t type, mapscr* theScreen, int32_t xoff, int32_t yoff) | |
| 10948 | { | ||
| 10949 | 6542704 | color_map = &trans_table2; | |
| 10950 | |||
| 10951 | //was this next variable ever used? -- DN | ||
| 10952 | //bool drawsubscr=false; | ||
| 10953 | |||
| 10954 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6542704 times.
|
6542704 | if(type > 7) |
| 10955 | ✗ | return; | |
| 10956 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6542704 times.
|
6542704 | if(theScreen->hidescriptlayers & (1<<type)) |
| 10957 | ✗ | return; //Script draws hidden for this layer | |
| 10958 | //--script_drawing_commands[][] reference-- | ||
| 10959 | //[][0]: type | ||
| 10960 | //[][1-16]: defined by type | ||
| 10961 | //[][17]: unused | ||
| 10962 | //[][18]: rendertarget | ||
| 10963 | //[][19]: unused | ||
| 10964 | |||
| 10965 | // Trying to match the old behavior exactly... | ||
| 10966 |
2/2✓ Branch 0 taken 2756696 times.
✓ Branch 1 taken 3786008 times.
|
6542704 | const bool brokenOffset= ( (get_bit(extra_rules, er_BITMAPOFFSET)!=0) || (get_bit(quest_rules,qr_BITMAPOFFSETFIX)!=0) ); |
| 10967 | |||
| 10968 | 6542704 | bool isTargetOffScreenBmp = false; | |
| 10969 | 6542704 | const int32_t type_mul_10000 = type * 10000; | |
| 10970 | 6542704 | const int32_t numDrawCommandsToProcess = script_drawing_commands.Count(); | |
| 10971 | 6542704 | FFCore.numscriptdraws = numDrawCommandsToProcess; | |
| 10972 | 6542704 | int32_t xoffset=xoff, yoffset=yoff; | |
| 10973 |
2/2✓ Branch 0 taken 381336 times.
✓ Branch 1 taken 6542704 times.
|
6924040 | for(int32_t i(0); i < numDrawCommandsToProcess; ++i) |
| 10974 | { | ||
| 10975 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 381336 times.
|
381336 | if(!brokenOffset) |
| 10976 | { | ||
| 10977 | 381336 | xoffset = 0; | |
| 10978 | 381336 | yoffset = 0; | |
| 10979 | 381336 | } | |
| 10980 | 381336 | int32_t *sdci = &script_drawing_commands[i][0]; | |
| 10981 | |||
| 10982 |
2/2✓ Branch 0 taken 330825 times.
✓ Branch 1 taken 50511 times.
|
381336 | if(sdci[1] != type_mul_10000) |
| 10983 | 330825 | continue; | |
| 10984 | // get the correct render target, if set. | ||
| 10985 | 50511 | BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[18]); | |
| 10986 | |||
| 10987 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 50511 times.
|
50511 | if(!bmp) |
| 10988 | { | ||
| 10989 | // draw to screen with subscreen offset | ||
| 10990 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 50511 times.
|
50511 | if(!brokenOffset) |
| 10991 | { | ||
| 10992 | 50511 | xoffset = xoff; | |
| 10993 | 50511 | yoffset = yoff; | |
| 10994 | 50511 | } | |
| 10995 | 50511 | bmp = targetBitmap; | |
| 10996 | 50511 | } | |
| 10997 | else | ||
| 10998 | { | ||
| 10999 | //not drawing to screen, so no subscreen offset | ||
| 11000 | ✗ | if(brokenOffset) | |
| 11001 | { | ||
| 11002 | ✗ | xoffset = 0; | |
| 11003 | ✗ | yoffset = 0; | |
| 11004 | } | ||
| 11005 | ✗ | isTargetOffScreenBmp = true; | |
| 11006 | } | ||
| 11007 | |||
| 11008 |
3/82✗ Branch 0 not taken.
✓ Branch 1 taken 22803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 880 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 26828 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
|
50511 | switch(sdci[0]) |
| 11009 | { | ||
| 11010 | case RECTR: | ||
| 11011 | { | ||
| 11012 | 22803 | do_rectr(bmp, sdci, xoffset, yoffset); | |
| 11013 | } | ||
| 11014 | 22803 | break; | |
| 11015 | case FRAMER: | ||
| 11016 | { | ||
| 11017 | ✗ | do_framer(bmp, sdci, xoffset, yoffset); | |
| 11018 | } | ||
| 11019 | ✗ | break; | |
| 11020 | |||
| 11021 | |||
| 11022 | case CIRCLER: | ||
| 11023 | { | ||
| 11024 | ✗ | do_circler(bmp, sdci, xoffset, yoffset); | |
| 11025 | } | ||
| 11026 | ✗ | break; | |
| 11027 | |||
| 11028 | case ARCR: | ||
| 11029 | { | ||
| 11030 | ✗ | do_arcr(bmp, sdci, xoffset, yoffset); | |
| 11031 | } | ||
| 11032 | ✗ | break; | |
| 11033 | |||
| 11034 | case ELLIPSER: | ||
| 11035 | { | ||
| 11036 | ✗ | do_ellipser(bmp, sdci, xoffset, yoffset); | |
| 11037 | } | ||
| 11038 | ✗ | break; | |
| 11039 | |||
| 11040 | case LINER: | ||
| 11041 | { | ||
| 11042 | ✗ | do_liner(bmp, sdci, xoffset, yoffset); | |
| 11043 | } | ||
| 11044 | ✗ | break; | |
| 11045 | |||
| 11046 | case SPLINER: | ||
| 11047 | { | ||
| 11048 | ✗ | do_spliner(bmp, sdci, xoffset, yoffset); | |
| 11049 | } | ||
| 11050 | ✗ | break; | |
| 11051 | |||
| 11052 | case PUTPIXELR: | ||
| 11053 | { | ||
| 11054 | ✗ | do_putpixelr(bmp, sdci, xoffset, yoffset); | |
| 11055 | } | ||
| 11056 | ✗ | break; | |
| 11057 | case PIXELARRAYR: | ||
| 11058 | { | ||
| 11059 | //Z_scripterrlog("Reached case PIXELARRAYR\n"); | ||
| 11060 | ✗ | do_putpixelsr(bmp, i, sdci, xoffset, yoffset); | |
| 11061 | } | ||
| 11062 | ✗ | break; | |
| 11063 | |||
| 11064 | case TILEARRAYR: | ||
| 11065 | { | ||
| 11066 | //Z_scripterrlog("Reached case PIXELARRAYR\n"); | ||
| 11067 | ✗ | do_fasttilesr(bmp, i, sdci, xoffset, yoffset); | |
| 11068 | } | ||
| 11069 | ✗ | break; | |
| 11070 | |||
| 11071 | case LINESARRAY: | ||
| 11072 | { | ||
| 11073 | //Z_scripterrlog("Reached case PIXELARRAYR\n"); | ||
| 11074 | ✗ | do_linesr(bmp, i, sdci, xoffset, yoffset); | |
| 11075 | } | ||
| 11076 | ✗ | break; | |
| 11077 | |||
| 11078 | case COMBOARRAYR: | ||
| 11079 | { | ||
| 11080 | //Z_scripterrlog("Reached case PIXELARRAYR\n"); | ||
| 11081 | ✗ | do_fastcombosr(bmp, i, sdci, xoffset, yoffset); | |
| 11082 | } | ||
| 11083 | ✗ | break; | |
| 11084 | |||
| 11085 | |||
| 11086 | |||
| 11087 | case DRAWTILER: | ||
| 11088 | { | ||
| 11089 | ✗ | do_drawtiler(bmp, sdci, xoffset, yoffset); | |
| 11090 | } | ||
| 11091 | ✗ | break; | |
| 11092 | |||
| 11093 | case DRAWTILECLOAKEDR: | ||
| 11094 | { | ||
| 11095 | ✗ | do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); | |
| 11096 | } | ||
| 11097 | ✗ | break; | |
| 11098 | |||
| 11099 | case DRAWCOMBOR: | ||
| 11100 | { | ||
| 11101 | ✗ | do_drawcombor(bmp, sdci, xoffset, yoffset); | |
| 11102 | } | ||
| 11103 | ✗ | break; | |
| 11104 | |||
| 11105 | case DRAWCOMBOCLOAKEDR: | ||
| 11106 | { | ||
| 11107 | ✗ | do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); | |
| 11108 | } | ||
| 11109 | ✗ | break; | |
| 11110 | |||
| 11111 | case FASTTILER: | ||
| 11112 | { | ||
| 11113 | ✗ | do_fasttiler(bmp, sdci, xoffset, yoffset); | |
| 11114 | } | ||
| 11115 | ✗ | break; | |
| 11116 | |||
| 11117 | case FASTCOMBOR: | ||
| 11118 | { | ||
| 11119 | 880 | do_fastcombor(bmp, sdci, xoffset, yoffset); | |
| 11120 | } | ||
| 11121 | 880 | break; | |
| 11122 | |||
| 11123 | case DRAWCHARR: | ||
| 11124 | { | ||
| 11125 | ✗ | do_drawcharr(bmp, sdci, xoffset, yoffset); | |
| 11126 | } | ||
| 11127 | ✗ | break; | |
| 11128 | |||
| 11129 | case DRAWINTR: | ||
| 11130 | { | ||
| 11131 | ✗ | do_drawintr(bmp, sdci, xoffset, yoffset); | |
| 11132 | } | ||
| 11133 | ✗ | break; | |
| 11134 | |||
| 11135 | case DRAWSTRINGR: | ||
| 11136 | { | ||
| 11137 | 26828 | do_drawstringr(bmp, i, sdci, xoffset, yoffset); | |
| 11138 | } | ||
| 11139 | 26828 | break; | |
| 11140 | |||
| 11141 | case DRAWSTRINGR2: | ||
| 11142 | { | ||
| 11143 | ✗ | do_drawstringr2(bmp, i, sdci, xoffset, yoffset); | |
| 11144 | } | ||
| 11145 | ✗ | break; | |
| 11146 | |||
| 11147 | case QUADR: | ||
| 11148 | { | ||
| 11149 | ✗ | do_drawquadr(bmp, sdci, xoffset, yoffset); | |
| 11150 | } | ||
| 11151 | ✗ | break; | |
| 11152 | |||
| 11153 | case QUAD3DR: | ||
| 11154 | { | ||
| 11155 | ✗ | do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); | |
| 11156 | } | ||
| 11157 | ✗ | break; | |
| 11158 | |||
| 11159 | case TRIANGLER: | ||
| 11160 | { | ||
| 11161 | ✗ | do_drawtriangler(bmp, sdci, xoffset, yoffset); | |
| 11162 | } | ||
| 11163 | ✗ | break; | |
| 11164 | |||
| 11165 | case TRIANGLE3DR: | ||
| 11166 | { | ||
| 11167 | ✗ | do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); | |
| 11168 | } | ||
| 11169 | ✗ | break; | |
| 11170 | |||
| 11171 | case POLYGONR: | ||
| 11172 | { | ||
| 11173 | ✗ | do_polygonr(bmp, i, sdci, xoffset, yoffset); | |
| 11174 | } | ||
| 11175 | ✗ | break; | |
| 11176 | |||
| 11177 | |||
| 11178 | case BITMAPR: | ||
| 11179 | { | ||
| 11180 | ✗ | do_drawbitmapr(bmp, sdci, xoffset, yoffset); | |
| 11181 | } | ||
| 11182 | ✗ | break; | |
| 11183 | |||
| 11184 | case BITMAPEXR: | ||
| 11185 | { | ||
| 11186 | ✗ | do_drawbitmapexr(bmp, sdci, xoffset, yoffset); | |
| 11187 | } | ||
| 11188 | ✗ | break; | |
| 11189 | |||
| 11190 | case DRAWLAYERR: | ||
| 11191 | { | ||
| 11192 | ✗ | do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); | |
| 11193 | } | ||
| 11194 | ✗ | break; | |
| 11195 | |||
| 11196 | case DRAWSCREENR: | ||
| 11197 | { | ||
| 11198 | ✗ | do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); | |
| 11199 | } | ||
| 11200 | ✗ | break; | |
| 11201 | |||
| 11202 | ✗ | case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break; | |
| 11203 | ✗ | case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break; | |
| 11204 | ✗ | case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break; | |
| 11205 | ✗ | case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break; | |
| 11206 | ✗ | case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break; | |
| 11207 | ✗ | case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break; | |
| 11208 | ✗ | case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break; | |
| 11209 | ✗ | case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break; | |
| 11210 | ✗ | case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break; | |
| 11211 | ✗ | case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break; | |
| 11212 | ✗ | case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break; | |
| 11213 | ✗ | case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break; | |
| 11214 | ✗ | case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break; | |
| 11215 | ✗ | case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break; | |
| 11216 | ✗ | case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break; | |
| 11217 | ✗ | case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break; | |
| 11218 | ✗ | case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break; | |
| 11219 | ✗ | case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break; | |
| 11220 | ✗ | case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break; | |
| 11221 | ✗ | case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break; | |
| 11222 | |||
| 11223 | ✗ | case BITMAPGETPIXEL: bmp_do_getpixelr(bmp, sdci, xoffset, yoffset); break; | |
| 11224 | ✗ | case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break; | |
| 11225 | ✗ | case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break; | |
| 11226 | ✗ | case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break; | |
| 11227 | ✗ | case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11228 | ✗ | case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11229 | ✗ | case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11230 | ✗ | case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11231 | ✗ | case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11232 | ✗ | case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11233 | ✗ | case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11234 | ✗ | case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break; | |
| 11235 | ✗ | case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break; | |
| 11236 | ✗ | case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break; | |
| 11237 | ✗ | case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break; | |
| 11238 | ✗ | case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break; | |
| 11239 | ✗ | case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break; | |
| 11240 | ✗ | case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break; | |
| 11241 | ✗ | case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break; | |
| 11242 | |||
| 11243 | ✗ | case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11244 | ✗ | case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11245 | ✗ | case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11246 | ✗ | case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11247 | ✗ | case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break; | |
| 11248 | ✗ | case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break; | |
| 11249 | ✗ | case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break; | |
| 11250 | ✗ | case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break; | |
| 11251 | ✗ | case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break; | |
| 11252 | ✗ | case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break; | |
| 11253 | ✗ | case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break; | |
| 11254 | } | ||
| 11255 | 50511 | } | |
| 11256 | |||
| 11257 | |||
| 11258 | 6542704 | color_map=&trans_table; | |
| 11259 | 6542704 | } | |
| 11260 | |||
| 11261 | 829899 | void CScriptDrawingCommands::Clear() | |
| 11262 | { | ||
| 11263 | 829899 | scb.update(); | |
| 11264 |
2/2✓ Branch 0 taken 590124 times.
✓ Branch 1 taken 239775 times.
|
829899 | if(commands.empty()) |
| 11265 | 590124 | return; | |
| 11266 | |||
| 11267 | //only clear what was used. | ||
| 11268 | 239775 | memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars)); | |
| 11269 | 239775 | count = 0; | |
| 11270 | |||
| 11271 | 239775 | draw_container.Clear(); | |
| 11272 | 829899 | } | |
| 11273 | ✗ | CScriptDrawingCommands* CScriptDrawingCommands::pop_commands() | |
| 11274 | { | ||
| 11275 | ✗ | CScriptDrawingCommands* ret = new CScriptDrawingCommands(); | |
| 11276 | ✗ | if(commands.empty()) | |
| 11277 | ✗ | return ret; | |
| 11278 | ✗ | ret->push_commands(this, false); | |
| 11279 | |||
| 11280 | ✗ | memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars)); | |
| 11281 | ✗ | count = 0; | |
| 11282 | |||
| 11283 | ✗ | draw_container.Clear(); | |
| 11284 | ✗ | return ret; | |
| 11285 | } | ||
| 11286 | ✗ | void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del) | |
| 11287 | { | ||
| 11288 | ✗ | commands.insert(commands.end(), other->commands.begin(), other->commands.end()); | |
| 11289 | ✗ | count += other->count; | |
| 11290 | ✗ | if(del) delete other; | |
| 11291 | } | ||
| 11292 | |||
| 11293 | 30 | void do_script_draws(BITMAP *targetBitmap, mapscr* theScreen, int32_t xoff, int32_t yoff, bool hideLayer7) | |
| 11294 | { | ||
| 11295 |
1/2✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
|
30 | if(XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff); |
| 11296 |
1/2✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
|
30 | if(XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff); |
| 11297 | 30 | do_primitives(targetBitmap, 0, theScreen, xoff, yoff); | |
| 11298 | 30 | do_primitives(targetBitmap, 1, theScreen, xoff, yoff); | |
| 11299 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if(!XOR(theScreen->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(targetBitmap, 2, theScreen, xoff, yoff); |
| 11300 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if(!XOR(theScreen->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(targetBitmap, 3, theScreen, xoff, yoff); |
| 11301 | 30 | do_primitives(targetBitmap, 4, theScreen, xoff, yoff); | |
| 11302 | 30 | do_primitives(targetBitmap, 5, theScreen, xoff, yoff); | |
| 11303 | 30 | do_primitives(targetBitmap, 6, theScreen, xoff, yoff); | |
| 11304 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
|
30 | if(!hideLayer7) do_primitives(targetBitmap, 7, theScreen, xoff, yoff); |
| 11305 | 30 | } | |
| 11306 |